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)); ?>
php push-notification apple-push-notifications codenameone
Kyri33
source share