Server side code for push notification [getting status 401]

You must Login before you can answer or comment on any questions.

I have implemented client using link , now i want to write server for it, i did try the js sdk given on link .. but it is failing on if(data.meta) {} ...after debugging i found out data.Statustext : TypeError: Access is denied.

— asked 11 months ago by Synechron Dev
2 Comments
  • Could you show us some code, so we might be able to help you better?

    — commented 11 months ago by Jacob Avlund

  • <script type="text/javascript"> function PushNotification() {

            var sdk = new Cocoafish('v4B7ZxZEj8ekkbJevfGLKME9lvc64xDT');  // app key 
    
            var data = {
                channel: 'alert',
                to_ids: '5006849a00204417fb0f531d',
                payload: 'Push Notification Test msg' 
            };
            debugger
            sdk.sendRequest('push_notification/notify.json', 'POST', data, callback);            
        }
    
    
        function callback(data) {
            debugger
            if (data) {
                if (data.meta) {
                    var meta = data.meta;
                    alert(&quot;Status &quot; + meta.status + &quot;  Code &quot; + meta.code);
                    if (meta.status == 'ok' &amp;&amp; meta.code == 200 &amp;&amp; meta.method_name == 'Notify') {
                        alert(&quot;Notification Send&quot; + meta.status);
                    }
                }
            }
        }
    
    &lt;/script&gt;
    

    — commented 10 months ago by Synechron Dev

1 Answer

<script type="text/javascript">
        function PushNotification() {
 
            var sdk = new Cocoafish('v4B7ZxZEj8ekkbJevfGLKME9lvc64xDT');  // app key 
 
            var data = {
                channel: 'alert',
                to_ids: '5006849a00204417fb0f531d',
                payload: 'Push Notification Test msg' 
            };
            debugger
            sdk.sendRequest('push_notification/notify.json', 'POST', data, callback);            
        }
 
 
        function callback(data) {
            debugger
            if (data) {
                if (data.meta) {
                    var meta = data.meta;
                    alert("Status " + meta.status + "  Code " + meta.code);
                    if (meta.status == 'ok' && meta.code == 200 && meta.method_name == 'Notify') {
                        alert("Notification Send" + meta.status);
                    }
                }
            }
        }
 
    </script>
its a aspx file, dot net server

Your Answer

Think you can help? Login to answer this question!