I want to implement firebase cloud messaging in iOS cordova app.
I tried cordovan-plugin-fcm
plugin It works in iOS 9 but not working with iOS 10.
My question is which was the best cordova firebase plugin to implement push notification? Is it iOS 9 or 10?
Try implementing this. https://github.com/fechanique/cordova-plugin-fcm
Then from your firebase account, Try to send notifications. It will work.
I try this and it works on simulator with ios 9.3 but if if try the same on simuator with ios 10.3 there is no message. This is my code:
FCMPlugin.getToken(function(token){
if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){
sendPushRegistration(token, 'android');
} else {
sendPushRegistration(token, 'ios');
}
});
FCMPlugin.onTokenRefresh(function(token){
if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){
sendPushRegistration(token, 'android');
} else {
sendPushRegistration(token, 'ios');
}
});
FCMPlugin.onNotification(function(data){
alert('onNotification');
if(data.wasTapped){
//Notification was received on device tray and tapped by the user.
alert( JSON.stringify(data) );
}else{
//Notification was received in foreground. Maybe the user needs to be notified.
alert( JSON.stringify(data) );
}
});
I get a token in the getToken function. But the onNotification function isn`t called in ios 10.3, in ios 9.3 it works. Plugin is cordova-plugin-fcm 2.1.2 "FCMPlugin" and the message was send by firebase console to one device.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.