Ionic3 Push notification

浪尽此生 提交于 2019-12-24 15:27:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!