我已经在我的应用程序中启用了推送通知,添加了构建提示,在play开发人员控制台上注册了API,在我的服务器上创建和加载了苹果证书。当我在设备上测试应用程序时,它成功地注册了推送通知。然而,我的问题在于尝试发送推送通知。我想通过PHP发送。我使用的代码直接来自开发人员指南。但是这并不起作用...这是我的代码有问题还是我在启用推送通知过程中做错了什么?
<?php
include("config.php");
$args = http_build_query(array( 'certPassword' => 'XXXXXXXX', 'cert'
=>
'http://kyven.co.za/mibrand/certificate/XXXX.p12',
'production' => false,
'device' => null, 'packageName' => 'za.co.bonyelo.mibrand', 'email'
=>
'kyri88@gmail.com', 'type' => 1,
'auth' => 'XXXXXXXXXXXXXXXXXXXXXXXXXX',
'body' => 'Test'));
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content'
=> $args
) );
$context = stream_context_create($opts);
$response = file_get_contents("https://codename-
one.appspot.com/sendPushMessage", false, $context);
die(json_encode($response));
?>