Android GCM push notification without server OR GCM push notification using Microsoft SQL(Not Mysql) and WCF service(Not PHP)

假装没事ソ 提交于 2019-12-12 21:28:35

问题


Hello to all, I am trying to create android GCM without using server. I don't want to store. Because i don't have server.Is it possible?

If it's not possible then i want to store using WCF Service and MS SQL(Microsoft SQL). In online search all are given sample codes using PHP and MySQL. If any one know WCF service and MS SQL sample code means give me a refer.

Thanks in advance.


回答1:


To send push notifications, all you have to do is make a post request to

https://gcm-http.googleapis.com/gcm/send with autrhorization key in header and a json content in body.

for ex:

Content-Type:application/json
Authorization:key=LEFskdjfajskdfhaskjdhf....

{ "data": {
    "message": "Hello world!!",
    "time": "10:15"
},
"to" : "alsdkfjT0:EFHwgIpoDKCIZvvDMExUdFQ3P1....."
}

so what you have to do is:

  1. Create a project on Google Cloud Console. go to https://console.developers.google.com
  2. Among google APIs go to Google Cloud Messaging, and enable the api.
  3. After enabling go to credentials and create a Api key from there.
  4. Now you are ready for cloud messaging. All you need is the id of the clients whom you want to send to.
  5. This you will get from your android client by setting up the client there.
  6. Now you can even make this post request right from your computer on desktop application (with correct api key) to send a push notification to android client (you must know the client key).

I don't know how you will get the client ids if you don't have a server! However, you now know how to send that push, all you need is some mechanism to get that with some sort of webservice, WCF in your case.

you can also develop web apps for free on google app engine (based on quotas), in case you are looking to get a free server. Happy Coding!



来源:https://stackoverflow.com/questions/37138562/android-gcm-push-notification-without-server-or-gcm-push-notification-using-micr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!