【问题标题】:How to add hidden data on Apple Push Notification如何在 Apple Push Notification 上添加隐藏数据
【发布时间】:2013-07-31 02:56:45
【问题描述】:

我正在使用这个 Ruby 脚本来发送推送通知:

APNS.host = 'gateway.push.apple.com' 
APNS.port = 2195 
APNS.pem  = 'CERTIFICATE_PATH
APNS.pass = '56895689aA'
device_token = TOKEN
APNS.send_notification(device_token, :alert => 'Message', :badge => 1, :sound =>     'beep.wav')

我正在像这样的设备(它的 Phonegap)上处理它

onAPNNotification: function (event) {
    var pushNotification = window.plugins.pushNotification;
    if (event.alert) {
        navigator.notification.alert(event.alert);
    }
    if (event.badge) {
        console.log("Set badge on  " + pushNotification);
        pushNotification.setApplicationIconBadgeNumber(this.onGCMRegisterSuccess, event.badge);
    }
    if (event.sound) {
        var snd = new Media(event.sound);
        snd.play();
    }
}

一切正常,我收到了通知,但我想知道是否有隐藏数据,以便在通知到达时不会显示(并显示带有通知中一些文本的警报)。

我们将不胜感激。

【问题讨论】:

    标签: javascript cordova push-notification phonegap-build


    【解决方案1】:

    示例中的有效负载使用 aps 字典来请求设备显示一条警报消息,左侧带有关闭按钮,右侧带有“操作”按钮的本地化标题。在这种情况下,“PLAY”用作当前所选语言的 Localizable.strings 文件的键,以获得“Play”的本地化等效项。 aps 字典还要求应用程序图标带有数字 5 的标记。

    {
    "aps" : {
        "alert" : {
            "body" : "Bob wants to play poker",
            "action-loc-key" : "PLAY"
        },
        "badge" : 5,
    },
    "acme1" : "bar",
    "acme2" : [ "bang",  "whiz" ]
    }
    

    欲了解更多信息:Apple Dev

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多