【问题标题】:Send push Notification in Ionic在 Ionic 中发送推送通知
【发布时间】:2020-06-25 08:03:17
【问题描述】:

我正在开发一个离子应用程序,需要使用在 .NET 中开发的后端 API 来实现推送通知。

在浏览几篇博客时,我发现了 Firebase API,并且能够使用 Firebase 完成 POC。但是,当应用处于前台时,通知并未显示。

我不确定如何使用 .NET API 来获取推送消息。我们可以在不使用 Firebase 的情况下实现这一目标吗?请建议。谢谢 !

【问题讨论】:

    标签: android firebase ionic-framework push-notification


    【解决方案1】:

    使用 firebase 通知不会在前台显示通知是正常的。

    this.firebase.onNotificationOpen().subscribe( (msg) => { 
        if (this.platform.is('ios')) { 
            this.presentToast(msg.aps.alert);
             //here notfication in ios
        } else { 
            this.presentToast(msg.body); 
            //here notfication in android
        } 
    });
    

    这将在前台触发通知。如果您希望它作为通知,请使用本地通知并设置 msg.body 详细信息,因为它应该显示在本地通知中。

    作为建议,请使用 onesignal 通知,因为它包含更好的功能,而且更简单、更灵活。

    【讨论】:

    • 谢谢@Mostafa!我们可以在 .NET 中集成 FCM 和 OneSignal 服务来推送和记录消息吗?
    • 你的意思是像日程通知这样的记录通知吗?
    • 是的,我希望根据我数据库中的某些条件单独向特定人员发送通知。我使用 .NET 开发了我的 API。
    • 是的,您可以轻松地使用 onesignal api,您只需要添加 includeSegments: [并发送用户玩家 ID] 并添加 sendAfter:time 以按计划发送
    猜你喜欢
    • 1970-01-01
    • 2015-08-19
    • 2018-07-01
    • 2020-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-29
    • 2018-12-25
    相关资源
    最近更新 更多