gpt4 book ai didi

ios - PhoneGap PushPlugin - 访问 iOS APNS 负载?

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:06:27 25 4
gpt4 key购买 nike

将 PushPlugin 与我的 PhoneGap 3 iOS 应用程序结合使用,我的推送通知大部分都可以正常工作,但我正在使用自定义负载向 APNS 发送通知。这是它的样子:

$body = array(
'customID' => $customID
);
$body['aps'] = array(
'alert' => $message,
'sound' => 'default'
);

据我所知,这应该由 APNS ( scroll down to the bottom ) 支持,但是 PushPlugin's documentation根本不能很好地处理 iOS。我想要的是在通过点击通知打开我的应用程序时能够将 customID 作为 JS 变量访问。当应用程序自行启动时,我不希望发生任何特殊情况。此外,用户点击了哪个通知很重要 - customID 是唯一且重要的。我真的很困惑,因为我找不到任何人谈论使用 PushPlugin 处理这些自定义 APNS 有效负载。

最佳答案

将自定义变量添加到推送通知有效负载的正确方法不是将其添加到 aps 命名空间(此命名空间由 Apple 保留),而是单独添加,例如:

$body['aps'] = array(
'alert' => $message,
'sound' => 'default'
);

$body['payload'] = array(
'customID' => $customID
);

在 PhoneGap 中,您可以在通知回调(例如 onNotificationAPN)中读取它,如下所示:

function onNotificationAPN (e) {
if (e.customID)
{
navigator.notification.alert("CustomID: " + e.customID);
}

关于ios - PhoneGap PushPlugin - 访问 iOS APNS 负载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21917624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com