用php问题代理推送通知

Kyr*_*i33 8 php push-notification apple-push-notifications codenameone

我在我的应用程序中启用了推送通知,添加了构建提示,在play开发者控制台上注册了api,在我的服务器上创建并加载了Apple证书.当我在设备上测试应用程序时,它成功注册了推送通知.但是我的问题是尝试实际发送推送通知.我希望它通过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));
?>
Run Code Online (Sandbox Code Playgroud)

Kyr*_*i33 3

知道了。这是我使用的代码

<?php

include("config.php");

$args = http_build_query(array('token' => 'XXXXXXXXXXXXXXXXXXX',
'certPassword' => 'XXXXXXXX', 'cert' =>     
'http://XXXXXXX/XXXXX/XXXXX/Certificates.p12',
'production' => false,
'device' => 'cn1-ios-XXXXXXXXXXXXXXXXXXXXXXXX',
 'packageName' => 'za.co.bonyelo.mibrand', 'email' =>    
'kyri88@gmail.com', 'type' => 1,
'auth' => 'XXXXXXXXXXX',
'body' => 'EAT MY BALLS'));
 $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://push.codenameone.com/push/push", false,   
$context);

die(json_encode($response));

 ?>
Run Code Online (Sandbox Code Playgroud)