问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/50770869/ionic3-push-notification