Hi all IONIC 2 Developers,
I have problem with android notification. I pushed notification from server to mobile, I pushed to mobile succeed already, but I cannot get even of notification when user clicked application icon.
Question: I would like to view detail page after user clicked on application icon (notification sent) or after user clicked on application icon it will alert the word “hey”?
Noted: I pushed notification succeed already, but I cannot get even of notification sent from server.
This is my ionic info:
Cordova CLI: Not installed
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.36
Ionic App Lib Version: 2.0.0-beta.19
ios-deploy version: Not installed
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v6.3.1
Xcode version: Xcode 8.1 Build version 8B62
This are my plugins:
cordova-plugin-compat 1.0.0 "Compat"
cordova-plugin-console 1.0.3 "Console"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-geolocation 2.2.0 "Geolocation"
cordova-plugin-inappbrowser 1.4.0 "InAppBrowser"
cordova-plugin-network-information 1.3.0 "Network Information"
cordova-plugin-spinner-dialog 1.3.1 "SpinnerDialog"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
cordova-sqlite-storage 1.4.9 "Cordova sqlite storage plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-push 1.8.4 “PushPlugin”
This is code on mobile:
this.platform.ready().then(() => {
StatusBar.styleDefault();
let push = Push.init({
android: {
senderID: “612733241092”,
forceShow : true
},
ios: {
alert: true,
badge: true,
sound: true
},
windows: {}
});
push.on(‘registration’, (data) => {
let device = this.platform.platforms();
let parm = {key: data.registrationId.toString(), os_type: device[2], field: “”, field_val: “”, isClick: “”};
this.load(‘http://easyfind.codingate.com/en/admin/api/num_token_field’, parm)
.then(data => {});
});
push.on('notification', (data) => {
alert("hey");
if (!data.additionalData.foreground) {
alert("hey clicked");
}
});
push.on('error', (e) => {
alert(JSON.stringify(e.message));
});
}