Pushwoosh:使用PHP API设置徽章

时间:2016-02-10 09:22:22

标签: php ios push-notification apple-push-notifications pushwoosh

我正在使用付费的Pushwoosh帐户,以便以编程方式向用户发送推送通知。

我已经实现了Pushwoosh PHP SDK并且一切正常,但我无法在iOS设备上设置通知 - 徽章,如下图所示:

enter image description here

到目前为止我的代码是:

$devicesArr[] = ...

$pushwoosh = Pushwoosh::create()
                        ->setApplication('79XXX-9CXXX')
                        ->setAuth('Wkf...2C8');

//Create the Message
$request = CreateMessageRequest::create()
                        ->addNotification(Notification::create()
                        ->setContent('A new workout is available!')
                        ->setDevices($devicesArr));

//Call the REST Web Service
$response = $pushwoosh->createMessage($request);

我尝试根据this page使用->setBadge(5)方法,但这也不起作用:

$request = SetBadgeRequest::create()
    ->setBadge(1)
    ->setHwid('18D...1AF');

你知道如何实现我的目标吗?

2 个答案:

答案 0 :(得分:0)

我无法在Cordova Sample(https://github.com/Pushwoosh/pushwoosh-phonegap-cordova-sample/tree/master/Phonegap-iOS-Android-WP)上重现这一点,您能分享一个简单的样本吗?

您是否确定在收到徽章推送时应用已关闭?

答案 1 :(得分:0)

根据文档,这不是您在设备上设置徽章编号的方法。

  

重要

     

此方法不用于更新设备上的徽章值。   相反,请使用" ios_badges" /使用/ createMessage请求。参数。   http://docs.pushwoosh.com/docs/setbadge