【问题标题】:Codename one push notifications with php issue带有php问题的代号一推送通知
【发布时间】:2016-08-01 07:33:34
【问题描述】:

我已经在我的应用中启用了推送通知,添加了构建提示,在 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));
?>

【问题讨论】:

  • 如果看到您的帖子的唯一人是像我这样不了解 PHP 的人,那么添加赏金将无济于事。我在您的帖子中添加了 PHP 标记
  • 您收到的回复是什么?
  • @Andrew 它是空的

标签: php push-notification apple-push-notifications codenameone


【解决方案1】:

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

<?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));

 ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-18
    • 2016-08-27
    • 1970-01-01
    • 1970-01-01
    • 2017-08-21
    • 2018-03-29
    • 1970-01-01
    相关资源
    最近更新 更多