【问题标题】:How to Send Push notification in Ionic Framework?如何在 Ionic 框架中发送推送通知?
【发布时间】:2016-09-05 10:00:49
【问题描述】:

如何使用基于 Ionic 框架的 Android 混合应用程序发送推送通知。 我是新手,请逐步指导我如何在 ionic 中发送推送通知? 我在 youtube 和其他网站上看到了不同的教程,但我很困惑在哪里添加这些网站上显示的代码。我有 GCM 项目编号 (SENDER_ID) 但不知道放在哪里。 请详细指导。 提前致谢。

【问题讨论】:

标签: android ionic-framework push-notification ionic2 hybrid


【解决方案1】:

尝试使用phonegap-plugin-push 吗?它易于实现和使用。

配置:

    var push = PushNotification.init({
        "android": {
            "senderID": "Your-sender-ID",
            "forceShow": true, // To show notifications on screen as well
            "iconColor": "#403782",
            "badge": "true",
            "clearBadge": "true" // To clear app badge
        },
        "ios": {
            "alert": "true",
            "badge": "true",
            "clearBadge": "true",
            "sound": "true",
            "forceShow": "true"
        },
        "windows": {}
    });

设备注册:

    push.on('registration', function(data) {
            localStorage.setItem('pushToken', data.registrationId); // Save registration ID
    });

处理通知

    push.on('notification', function(data) {
        console.log(data);
        // Handle all requests here
        if (data.additionalData.$state == "mystate") {
            $state.go('app.conversations');
        }
    })

【讨论】:

  • 没关系,以后可能有人需要这个。
猜你喜欢
  • 2016-08-10
  • 2020-06-25
  • 2018-07-01
  • 1970-01-01
  • 2015-08-19
  • 2020-04-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多