I've set up the push notification plugin and am calling the register method, but it's only returning a string "OK" instead of a device id. How do I get the registered device id?
$window.plugins.pushNotification.register(
function (result) {
q.resolve(result); //this always just returns the string "OK", how do I get the device ID?
},
function (error) {
console.log(error);
q.reject(error);
},
config);
return q.promise;
},
e.regid is null, taken from this example
// Android and Amazon Fire OS
function onNotification(e) {
$("#app-status-ul").append('<li>EVENT -> RECEIVED:' + e.event + '</li>');
switch( e.event )
{
case 'registered':
if ( e.regid.length > 0 )
{
$("#app-status-ul").append('<li>REGISTERED -> REGID:' + e.regid + "</li>");
// Your GCM push server needs to know the regID before it can push to this device
// here is where you might want to send it the regID for later use.
console.log("regID = " + e.regid);
}
break;
case 'message':
// if this flag is set, this noti
so I just mis-understood the callbacks in the push library. The register function callback on iOS returns a string token, wheras in Android it just returns a success handler. The registration event's token id in the Android version has to be handled on the push notification ecb handler rather than in the registration callback.
So in their example
the function is set in the config property "ecb" as "onNotification" and not in the sucess handler.
In which case you can use the onNotification example in the original question. My mistake was passing the onNotification function as the success handler in Android, which is not the case.