I am creating a mobile app using the Ionic wrapper for using angular on phones. Users register the app with the google cloud messaging serivce (GCM). This means the app will occasionally get a push notification which triggers a function. This function broadcasts a message on the root scope:
$rootScope.$broadcast("messageReceived", responseData.payload);
The current view has a controller on it which listens for this message, processes the data, then switches view to a different scope:
$scope.$on("messageReceived", function(event,data){
console.log("Messge receive listener firing!");
orders.setOrders(data.orders);
if(data.notificationType === "making"){
$location.path('/yourRound');
}
else if(data.notificationType === "receiving"){
console.log("Got into receiving bit");
orders.setBaristaName(data.baristaName);
$location.path('/waiting');
}
$scope.$apply();
});
When this "messageReceived" event is fired however, I get the following error in the inspector:
processMessage failed: Error: TypeError: Cannot read property '$$nextSibling' of null cordova.js:1058
processMessage failed: Stack: TypeError: Cannot read property '$$nextSibling' of null
at Scope.$broadcast (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:20617:57)
at self.onNotificationGCM (file:///android_asset/www/js/services/pushService.js:32:17)
at onNotification (file:///android_asset/www/js/services/pushService.js:45:17)
at eval (eval at processMessage (file:///android_asset/www/cordova.js:1020:26), <anonymous>:1:12)
at processMessage (file:///android_asset/www/cordova.js:1020:13)
at Function.androidExec.processMessages (file:///android_asset/www/cordova.js:1090:13)
at pollOnce (file:///android_asset/www/cordova.js:955:17)
at pollOnceFromOnlineEvent (file:///android_asset/www/cordova.js:945:5) cordova.js:1059
processMessage failed: Message: Jjavascript:onNotification({ ... Message contents etc...
Why is this happening? Is it related to the destruction of the scope/the asynchronous nature of the broadcast messages? The strange thing is that this error message is not actually causing any functionality to break. I can use the app as normal, it's just that this message appears in the debug inspector.