首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有办法在我们的ionic 4项目中使用推送通知?

有没有办法在我们的ionic 4项目中使用推送通知?
EN

Stack Overflow用户
提问于 2019-07-11 00:57:44
回答 2查看 1.1K关注 0票数 3

我们目前已经编写了一个Ionic和Firebase项目。在这个项目中,我们希望使用推送通知。但我们的麻烦是:我们正在寻找一个推送通知插件,就像WhatsApp应用程序。例如,当我们向一个人发送消息时,我们希望通知发到我们发短信的那个人,而不是每个人。但我们找不到一种免费的方法来做到这一点。你有什么意见建议?谢谢。

EN

回答 2

Stack Overflow用户

发布于 2019-07-12 02:51:59

使用cordova-和ionic-native的Firebase云消息传递插件:Ref. Url

代码语言:javascript
复制
  import { FCM } from '@ionic-native/fcm/ngx';

constructor(private fcm: FCM) {}

this.fcm.getToken().then(token => {

  //you can store device token in firebase, later you can target push notification from firebase console this token id
  backend.registerToken(token);
});

this.fcm.onNotification().subscribe(data => {
  if(data.wasTapped){  / * true , means the user tapped the notification from the notification tray and that’s how he opened the app. */
    console.log("Received in background");
  } else {// false , means that the app was in the foreground (meaning the user was inside the app at that moment)
    console.log("Received in foreground");
  };
});

this.fcm.onTokenRefresh().subscribe(token => {

  //update device token
  backend.registerToken(token);
});
票数 3
EN

Stack Overflow用户

发布于 2019-10-17 22:14:12

我不建议你使用FCM插件。它没有方法来管理您的应用程序中的通知(清除所有或清除一些特殊的通知。

最好使用phonegap-push-plugin或一个信号

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

https://stackoverflow.com/questions/56975392

复制
相关文章

相似问题

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