I suspect the B4X Push Server will be required... somewhere.
On the Android side, I can stuff new generated messages (outgoing) into a local table and using RDC, send back to server - No GCM required - I suspect.
My Android app currently registers to GCM correctly, and then tries to send using (php - bad):
jb.PostString(thesite&"/recmess.php?ar1="&dt&"&ar2="&nam&"&ar3="&mes&"&ar4="&comp_id&"&ar5="&DefCM.lat1&"&ar6="&DefCM.lon1 ,"")
It should receive messages from GCM without any issues since it just handles the incoming GCM, as it did in the past.
On the ABM/B4J server side, I would like to push these out using GCM.
This is my old code using PHP, which I would like to get rid of...
Thanks
On the Android side, I can stuff new generated messages (outgoing) into a local table and using RDC, send back to server - No GCM required - I suspect.
My Android app currently registers to GCM correctly, and then tries to send using (php - bad):
jb.PostString(thesite&"/recmess.php?ar1="&dt&"&ar2="&nam&"&ar3="&mes&"&ar4="&comp_id&"&ar5="&DefCM.lat1&"&ar6="&DefCM.lon1 ,"")
It should receive messages from GCM without any issues since it just handles the incoming GCM, as it did in the past.
On the ABM/B4J server side, I would like to push these out using GCM.
This is my old code using PHP, which I would like to get rid of...
B4X:
function sendGCM($UserID, $message) {
$query = "SELECT id From devices Where name=$UserID";
$row = mysql_fetch_object(mysql_query($query));
// Replace with real BROWSER API key from Google APIs
$apiKey = "AIzaSyAwsxxxxxxxxxxxxxxO3k"; // Browser Key
// Replace with real client registration IDs
$registrationIDs = array( $row->id );
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array( "data" => $message ),
);
$headers = array(
'Authorization: key=' . $apiKey,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
// Execute post
$result = curl_exec($ch);
// Close connection
curl_close($ch);
}
Thanks