Ionic3推送通知 [英] Ionic3 Push notification
本文介绍了Ionic3推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人在ionic 3
IOS
上处理通知吗?
尝试使用firabase push
(FCM)
的一周,但没有成功,大多数教程已过时...
有谁知道我可以使用的其他任何方式
或如果有人在IOS
中使用FCM
的示例项目供我使用/学习
Has anyone worked with notifications on ionic 3
IOS
?
to a week trying to use the firabase push
(FCM)
but without success, most of the tutorials are out of date ...
Does anyone know of any other way I can use
or if someone has some example project of using FCM
in IOS
for me to use / learn
推荐答案
在离子3中使用cordova-plugin-fcm
的代码示例.
Code sample of using cordova-plugin-fcm
in ionic 3.
import {Platform} from 'ionic-angular';
import { FCM } from '@ionic-native/fcm';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
constructor( private platform: Platform, private fcm: FCM ) {
platform.ready().then(() => {
this.initPushNotification();
});
}
initPushNotification() {
this.fcm.getToken().then(token => {
console.log(token);
// You can get and save push device token to your database.
});
this.fcm.onNotification().subscribe(data => {
//This callback function is called when mobile received a push notification
if (data.wasTapped) {
// You can handle logic after taping push message in notification bar
}
});
}
}
希望这会对您有所帮助.如果您需要更多,请告诉我.
Hope this will help you. if you need more let me know.
这篇关于Ionic3推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文