【问题标题】:push notification doesn't show up on status bar推送通知不显示在状态栏上
【发布时间】:2015-12-03 12:17:01
【问题描述】:

我将 phonegap 与 phonegap-plugin-push 一起使用,我尝试了插件附带的示例,我在手机(Galaxy s4,Android 5.0.1)上测试了它,当我在应用程序打开时发送通知时我收到了振动,并且消息显示在 index.js 中提到的卡片 div 中,但我在状态栏上没有收到通知,如果应用程序在后台,我在状态栏上也没有收到通知,但我收到了振动。我想知道为什么我在状态栏上没有弹出通知。 我使用 phonegap-plugin-push 1.4.4

【问题讨论】:

  • 您可以拨打您正在发送的电话吗?我现在正在使用它并且效果很好。

标签: android cordova phonegap-plugins phonegap-build phonegap-pushplugin


【解决方案1】:

@德尔

我正在使用 ruby​​ 发送通知

require 'rubygems'
require 'pushmeup'

GCM.host = 'https://android.googleapis.com/gcm/send'
GCM.format = :json
GCM.key = "key"
destination = ["id"]
data = {:title => "PhoneGap Push",:message => "PhoneGap Build rocks!",         :msgcnt => "1", :soundname => "beep.wav"}
options = {:collapse_key => "placar_score_global", :time_to_live => 3600, :delay_while_idle => false}

GCM.send_notification( destination, data, options)

【讨论】:

  • 我解决了,我添加了一个图标:它必须在我的 phonegap 项目的根目录中,并且已经完成。
  • Anass Boukalane - 你能给出示例代码吗?我也面临同样的问题
  • @Prithvi Raj Nandiwal 您必须在上面的 ruby​​ 代码中添加图标选项才能使其显示
【解决方案2】:

当您收到推送通知时,您还需要在该点发出本地通知,该通知将显示在您的状态栏和通知托盘中。我是 phonegap-plugin-localNotifications 插件的粉丝,你可以在 https://github.com/Wizcorp/phonegap-plugin-localNotifications 找到它。因此,在 Android 的 phonegap-plugin-push onNotification 处理程序中,您可以执行以下操作:

onNotification: function (e) {
    if (e.event == "message") {
        localNotification.add(1, {
            message: e.payload.message,
            badge: 1
        });
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-29
    • 1970-01-01
    • 2015-01-14
    • 2020-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多