How send push notification with php form to a device?

65 views
Skip to first unread message

Philippe DE LUCA

unread,
Feb 17, 2015, 6:08:15 AM2/17/15
to codenameone...@googlegroups.com
Hi,
I have access to a pro account and I would like to know what is the best way to send a push notification through the CN1 server in this scenario : a php form (back-office) sends push notification to a specific device (previously the device_id was stored in a mysql database with dedicated web-service).
Should I use in PHP "https://codename-one.appspot.com/sendPushMessage" url with concatenate POST arguments (body, deviceKey,AuthKey...) or is there another method more suitable?
thanks for your response

Shai Almog

unread,
Feb 17, 2015, 1:36:09 PM2/17/15
to codenameone...@googlegroups.com
Hi,
generally you can look at the code for Push.java to see how we do the push and adapt that: https://code.google.com/p/codenameone/source/browse/trunk/CodenameOne/src/com/codename1/push/Push.java

I don't know if this worked since I'm not a php developer but one of our users sent this a while back:
$args = http_build_query(array(

 
'certPassword' => 'CERTIFICATE_PASSWORD',

 
'cert' => 'LINK_TO_YOUR_P12_FILE',

 
'production' => false,

 
'device' => $device['deviceId'],

 
'packageName' => 'YOUR_APP_PACKAGE_HERE',

 
'email' => 'YOUR_EMAIL_ADDRESS_HERE',

 
'type' => 1,

 
'auth' => 'YOUR_GOOGLE_AUTH_KEY',

 
'body' => $wstext));

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


Reply all
Reply to author
Forward
0 new messages