有人使用过ionic 3 IOS上的通知吗?花了一周的时间尝试使用firabase push (FCM),但没有成功,大多数教程都过时了……是否有人知道我可以使用的其他方法,或者是否有人有一些在IOS中使用FCM的示例项目供我使用/学习
发布于 2018-06-09 13:08:36
在ionic 3中使用cordova-plugin-fcm的代码示例。
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
}
});
}
}希望这能对你有所帮助。如果你需要更多,请让我知道。
https://stackoverflow.com/questions/50770869
复制相似问题