I am trying to get the device registration ID to send him notifications from my server.
I have tried several times:
GambifyApp.NotificationManager = window.GambifyApp.NotificationManager = Ember.Object.extend({ init: function(){ var pushNotification = window.plugins.pushNotification; window.GambifyApp.NotificationHandler = GambifyApp.NotificationHandler; if ( device.platform == 'android' || device.platform == 'Android' ) { console.log('pushNotification Register'); pushNotification.register( this.successHandler, this.errorHandler, { "senderID":GambifyApp.config.android_sender_id, "ecb":"window.externalOnNotificationGCM" }); }, }); window.externalOnNotificationGCM = function (e) { console.log('reg id:' + e.regid); };
The approach was inside another object (everything remains unchanged, except for ECB:
"ecb":"window.GambifyApp.NotificationHandler.onHandler"
And this is where I put the handler:
GambifyApp.NotificationHandler = window.GambifyApp.NotificationHandler = { onHandler: function(e){ console.log('onHandler:'); if(e.event == "registered") { console.log('reg id:' + e.regid); } console.log(e); } }
My last approach with
"ecb":"GambifyApp.NotificationManager.onNotificationGCM"
And here are the additions to the manager class:
GambifyApp.NotificationManager = window.GambifyApp.NotificationManager = Ember.Object.extend({ onNotificationGCM: function(e){ console.log('MESSAGE received:'); console.log(e); } });
I also tried without a window object, etc. My sucess handler always starts, but never ECB.
source share