I write this lines to ask if someone has got a simliar problem like me and how can i try to solve it...
I use this plugin for register users in GCM for Android, and I call the register function every time that the user opens the apk for prevent some errors. But it isn't still enough, because after to get the token, I call Amazon Web Services to obtain or register (if i haven't got it) a new endpoint in my Amazon application.
I need that this workflow works always because this endpoint is used to send push notifications using a database and I observed that sometimes the register function fails giving me a null endpoint... After tested the call to Amazon Web Services I've seen that it's correct so i think to call the register function every time that i have an errorCallback making the code recursive.
This will be a good idea or any idea to make the code works 100% to success register every time?
Thanks in advance,
Oriol
The code (resumed):
pushNotification.register(successHandler, errorHandler, {"senderID":"783684761403","ecb":"onNotificationGCM"});
$window.onNotificationGCM = function(e) {
switch( e.event )
{
case 'registered':
token = e.regid;
$window.localStorage.setItem('token', JSON.stringify(e.regid));
amazon();
break;
}
}
function errorHandler (error) {
console.log(error);
reregister();
}
function reregister(){
console.log("Tornem a registrar, hi ha hagut error en el registre");
pushNotification.register(successHandler, errorHandler, {"senderID":"783684761403","ecb":"onNotificationGCM"}); // required!
}
Hello,
I write this lines to ask if someone has got a simliar problem like me and how can i try to solve it...
I use this plugin for register users in GCM for Android, and I call the register function every time that the user opens the apk for prevent some errors. But it isn't still enough, because after to get the token, I call Amazon Web Services to obtain or register (if i haven't got it) a new endpoint in my Amazon application.
I need that this workflow works always because this endpoint is used to send push notifications using a database and I observed that sometimes the register function fails giving me a null endpoint... After tested the call to Amazon Web Services I've seen that it's correct so i think to call the register function every time that i have an errorCallback making the code recursive.
This will be a good idea or any idea to make the code works 100% to success register every time?
Thanks in advance,
Oriol
The code (resumed):