2013-07-31 19 views
1

我使用这个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(); 
    } 
} 

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

任何帮助将是apreciated。

回答

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