简体   繁体   English

代号一推送通知与PHP问题

[英]Codename one push notifications with php issue

I've enabled push notifications in my app, added the build hints, registered the api on the play developer console, created and loaded the apple certificates on my server. 我已经在我的应用程序中启用了推送通知,添加了构建提示,在Play开发者控制台上注册了api,在服务器上创建并加载了苹果证书。 When I test the app on a device it successfully registers for push notifications. 当我在设备上测试应用程序时,它成功注册了推送通知。 However my issue comes in with trying to actually send a push notification. 但是我的问题来自尝试实际发送推送通知。 I want it to send through PHP. 我希望它通过PHP发送。 I use this code which is taken straight from the developer guide. 我使用的是直接从开发人员指南中获取的代码。 However this does not work... Is it a problem with my code or did I do something wrong in the enabling push notifications process. 但是,这不起作用...是我的代码有问题还是在启用推送通知过程中做错了什么。

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

Got it. 得到它了。 This is the code I used 这是我使用的代码

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

 ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM