gonzaloaune / GCMPushPlugin

Push notifications for Cordova (GCM & Native support)
MIT License
37 stars 20 forks source link

iOS:ReferenceError: Can't find variable: onNotification #13

Closed pliablepixels closed 8 years ago

pliablepixels commented 8 years ago

Hi folks, I am trying this with an ionic/angular App.

The registration etc. works fine, pushing works and I can see my device getting the notification but I think there is a problem in how the callback is defined.

The error I am getting:

2015-10-19 14:05:39.274 myApp[1039:527436] exeption nativeEvalAndFetch : ReferenceError: Can't find variable: onNotification

How I registered:

 window.GcmPushPlugin.register(successHandler, errorHandler, {
                "badge":"true",
                "sound":"true",
                "alert":"true",
                "usesGCM":true,
                "sandbox":true,
                "jsCallback":"onNotification"
            });

My functions

function successHandler(result) {
  console.log("************** Token: " + result.gcm);
}

function errorHandler(error) {
 console.log("************** Error: " + error);
}

function onNotification(notification)
 {
        console.log ("******** MESSAGE " + JSON.stringify(notification));
 }
pliablepixels commented 8 years ago

sorry, problem fixed I had to do

 window.onNotification = function(notification)
    {
        console.log ("******** GOT MESSAGE " + JSON.stringify(notification));
    };
comiguel commented 8 years ago

@pliablepixels Which versions of iOS you've tried?

edvenkat commented 8 years ago

window.onNotification function not working.....please advice