El error de referencia onnotification no está definido en la notificación de push cordova android
Utilizar Cordova (ionicframework + angularjs) Construir para usar las solicitudes de notificaciones push para dispositivos Android. Al hacer el registro El successHandler()
se dispara con el resultado del mensaje ('ok')! ¿Por qué el método onNotification()
no se dispara en ningún momento ??.
var pushNotification; document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { pushNotification = window.plugins.pushNotification; setupNotificationsForandroid(); } //begin setup function setupNotificationsForandroid() { // alert("inside setup"); if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){ pushNotification.register( successHandler, errorHandler, { "senderID":"856763042820", "ecb":"onNotification" }); } else { pushNotification.register( tokenHandler, errorHandler, { "badge":"true", "sound":"true", "alert":"true", "ecb":"onNotificationAPN" }); } } function successHandler(result){ //alert("success"+result); } function errorHandler(){ alert("error"); } // Android function onNotification(e) { //alert("inside onnotification"); switch( e.event ) { case 'registered': if ( e.regid.length > 0 ){ //set up the server call for storing registraion ids alert(e.regid); } break; case 'message': // if this flag is set, this notification happened while we were in the foreground. if(e.foreground){ var soundfile = e.soundname || e.payload.sound; var my_media = new Media("android/assets/www/"+ soundfile); my_media.play(); }else{ // otherwise we were launched because the user touched a notification in the notification tray. } break; case 'error': console.log("Error"+e.msg); break; default: console.log("An unknown event"); return; } }
Aquí está mi mensaje de la consola:
- La respuesta de GCM que viene es: Error = NotRegistered
- Enviar notificación con la apertura de Parse antes de hacer clic en la notificación
- Comportamiento de aplicaciones Android VOIP en modo Doze
- Notificaciones de Firebase en primer plano
- Notificaciones Push de XMPP (Openfire)
09-22 11:38:46.151: I/Web Console(24662): processMessage failed: Stack: ReferenceError: onNotification is not defined 09-22 11:38:46.151: I/Web Console(24662): at eval (eval at processMessage (file:///android_asset/www/cordova.js:1006:26), <anonymous>:1:1) 09-22 11:38:46.151: I/Web Console(24662): at processMessage (file:///android_asset/www/cordova.js:1006:13) 09-22 11:38:46.151: I/Web Console(24662): at Function.androidExec.processMessages (file:///android_asset/www/cordova.js:1076:13) 09-22 11:38:46.151: I/Web Console(24662): at pollOnce (file:///android_asset/www/cordova.js:944:17) 09-22 11:38:46.151: I/Web Console(24662): at pollOnceFromOnlineEvent (file:///android_asset/www/cordova.js:939:5) at file:///android_asset/www/cordova.js:1045 09-22 11:38:46.151: D/CordovaLog(24662): file:///android_asset/www/cordova.js: Line 1046 : processMessage failed: Message: Jjavascript:onNotification({"regid":"APA91bHDLg9BZl-eicx3tS-MjVGy-mcufmbRc-EpCuKzb9b_tPddG125jyxY-OhVR5vul6az-eJ2nZ0PEiOVPqP2KjClaUwAKTBQx5gsIluI0jsGIrpCvNQdUbtKUBxNNH0DH94RHuGpjU29xhTS5Cl8qIgH1MlJHw","event":"registered"})
Sobre la base de este processMessage failed: Stack: ReferenceError: onNotification is not defined
mensaje de la consola Creo que el problema con onNotification()
favor, ayude
- En algún momento no recibe notificación push GCM en Mobile
- Cómo agregar una notificación de inserción en mi propia aplicación de Android
- ¿Cómo los servidores de la conexión GCM envían mensajes a un dispositivo Android?
- ¿Cómo mostrar la imagen en notificación push (Gcm) android?
- URL de Firebase de Google Cloud Function Node.js
- Se ha producido un error en el registro de ServiceWorker: DOMException: Sólo se permiten orígenes seguros (consulte: https://goo.gl/Y0ZkNV)
- PHP del servidor GCM - Error 401 no autorizado
- ¿Cómo se juega un tono de timbre que es sólo para Push Notification Arrivals de mi aplicación?
OnNotification debe tener alcance en ventana.
window.onNotification = function(){ }