首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Ionic3推送通知

Ionic3推送通知
EN

Stack Overflow用户
提问于 2018-06-09 12:17:43
回答 1查看 460关注 0票数 1

有人使用过ionic 3 IOS上的通知吗?花了一周的时间尝试使用firabase push (FCM),但没有成功,大多数教程都过时了……是否有人知道我可以使用的其他方法,或者是否有人有一些在IOS中使用FCM的示例项目供我使用/学习

EN

回答 1

Stack Overflow用户

发布于 2018-06-09 13:08:36

在ionic 3中使用cordova-plugin-fcm的代码示例。

代码语言:javascript
运行
复制
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
            }
        });
    }
}

希望这能对你有所帮助。如果你需要更多,请让我知道。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50770869

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档