Hey guys,
Going nuts on that one. I keep getting that error when runing on my Android device:
.controller('InitialCtrl', function($rootScope, $scope, $cordovaPush, $cordovaDialogs, $cordovaMedia, $cordovaToast, $ionicPopup, $ionicPlatform) {
processMessage failed: Error: TypeError: Cannot read property 'get' of undefined
processMessage failed: Stack: TypeError: Cannot read property 'get' of undefined
at eval (eval at processMessage (file:///android_asset/www/cordova.js:1021:26), <anonymous>:1:74)
at processMessage (file:///android_asset/www/cordova.js:1021:13)
at Function.androidExec.processMessages (file:///android_asset/www/cordova.js:1091:13)
at pollOnce (file:///android_asset/www/cordova.js:956:17)
at pollOnceFromOnlineEvent (file:///android_asset/www/cordova.js:946:5)
processMessage failed: Message: Jjavascript:angular.element(document.querySelector('[ng-app]')).injector().get('$cordovaPush').onNotification({"event":"registered","regid":"APA91bFCuwFAveicLbPtR[...]"})
Where is that coming from?? ngCordova is loaded and here is the begining of my code :
Thanks for your help!!
$scope.notifications = [];
// call to register automatically upon device ready
$ionicPlatform.ready(function (device) {
var config = null;
if (ionic.Platform.isAndroid()) {
console.log('I am Android');
config = {
"senderID": "12345677 my id" // PROJECT ID FROM GCM CONSOLE
};
}
else if (ionic.Platform.isIOS()) {
console.log('I am iOS');
config = {
"badge": "true",
"sound": "true",
"alert": "true"
}
}
$cordovaPush.register(config).then(function (result) {
console.log("Register success " + result);
// ** Can be removed after test
$cordovaToast.showShortCenter('Registered for push notifications');
$scope.registerDisabled=true;
// ** NOTE: Android regid result comes back in the pushNotificationReceived, only iOS returned here
if (ionic.Platform.isIOS()) {
$scope.regId = result;
storeDeviceToken("ios");
}
}, function (err) {
console.log("Register error " + err)
});
});
// Notification Received
$rootScope.$on('$cordovaPush:notificationReceived', function (event, notification) {
console.log(JSON.stringify([notification]));
if (ionic.Platform.isAndroid()) {
handleAndroid(notification);
}
else if (ionic.Platform.isIOS()) {
handleIOS(notification);
$scope.$apply(function () {
$scope.notifications.push(JSON.stringify(notification.alert));
})
}
});
})