Hi all,
I’m trying to use phonegap-plugin-push for push notifications but I’m having trouble getting it to work and I’ve struggled to find a good example for use with the ionic framework. I’m able to get it fire the registration event fine and I receive a token but when I try sending a simple push notification through the firebase cloud messaging console usng the token nothing happens. Here is my code which I currently have in app.js:
.run(function($ionicPlatform ) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
var push = PushNotification.init({
"android": {
"senderID": "***********"
},
"ios": {"alert": "true", "badge": "true", "sound": "true"},
"windows": {}
});
push.on('registration', function(data) {
console.log("registration event: "+ data.registrationId);
//here is your registration id
});
push.on('notification', function(data){
console.log("Message: "+data.message)
var alertPopup = $ionicPopup.alert({
title: data.message,
});
});
push.on('error', function(e) {
console.log(e.message);
});
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
Can anyone help me out?
Thanks in advance.