Httpsocket post for using google gcm

Hi at all,

I would like to use Xojo for send notifications to my android phone.

I think use httpsocket with post method. But I don’t know how to implement this.

url for post : https://gcm-http.googleapis.com/gcm/send
header : Authorization: key=YOUR_API_KEY , Content-Type: application/json,
Content :
{ “notification”: {
“title”: “message title”,
“text”: “message text”
},
“to” : “bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1OZZUEJENEJENE”
}

Google doc : https://developers.google.com/cloud-messaging/http#example-responses

Thanks for your help :slight_smile:

Jrme

[quote=265296:@JrmeLeray]Hi at all,

I would like to use Xojo for send notifications to my android phone.

I think use httpsocket with post method. But I don’t know how to implement this.

url for post : https://gcm-http.googleapis.com/gcm/send
header : Authorization: key=YOUR_API_KEY , Content-Type: application/json,
Content :
{ “notification”: {
“title”: “message title”,
“text”: “message text”
},
“to” : “bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1OZZUEJENEJENE”
}

Google doc : https://developers.google.com/cloud-messaging/http#example-responses

Thanks for your help :slight_smile:

Jrme[/quote]

Solution :

[code] dim postText as Text = “{ ““data””: {”“message”": ““MY MESSAGE TO SEND””},"“registration_ids”" : ““MYDEVICE_ID””}"

mySocket.SetRequestHeader(“Authorization”, “key=MYGOOGLEAPIKEY”)
mySocket.SetRequestContent(postText, “application/json”)
mySocket.Post(“https://android.googleapis.com/gcm/send”)
[/code]