Codename - one-time notifications with php release

I turned on push notifications in my application, added build hints, registered api on the game developer console, created and uploaded Apple certificates on my server. When I test the application on the device, it successfully registers for push notifications. However, my problem is with the attempt to actually send a push notification. I want it to be sent via PHP. I use this code, which is taken directly from the developer's guide. However, this does not work ... Is this a problem with my code or I did something wrong in the process of enabling push notifications.

<?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)); ?> 
+8
php push-notification apple-push-notifications codenameone
source share
1 answer

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)); ?> 
+3
source share

All Articles