Cordoba Pushplugin: ecb not called

I am trying to get the device registration ID to send him notifications from my server.

I have tried several times:

  • External object

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); }; 
  1. 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); } } 
  1. 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.

+6
source share
1 answer

The problem was resolved by specifying ecb as window.GambifyApp.NotificationHandler.onNotificationGCM :

 pushNotification.register( this.successHandler, this.errorHandler, { "senderID":GambifyApp.config.android_sender_id, "ecb":"window.GambifyApp.NotificationHandler.onNotificationGCM" } ); 
+1
source

Source: https://habr.com/ru/post/977403/