简体   繁体   中英

Android send notification from device to other device using GCM and PHP

I need a help of how to send a notification from device to other device using the same application by GCM and PHP as a server.

can anyone provide me a simple example of how to register as a user and send message to another user. or provide me anything that will be useful to my application

I think I know what you are talking about. First things first, if you want to send a Google Cloud Message from device A to to device B, you must have the GCM registration Id of device B. (I hope you are not planning on storing device B's registration Id on device A)

Here is one approach

Create a registration page. Take a unique input from user like email address (don't forget to verify it) and get GCM registration Id. Then store this information in server with the unique input (email) as primary key and map it with GCM registration Id.

Now if you want the USER of the app, say user A to send some information to user B (like chatting app) call your PHP method from device A with user B's unique input (email address). Your web method can fetch the GCM registration Id for device B from the input parameter and can send a GCM message. you can get email address of user B, C, D etc. from user's contact book or contacts in the email address (or use social networking SDKs to get email address).

If you want your app to send GCM message from device A to device B without users consent, then also you either need the registration Id or the mapped unique key of device B (email in this example). I don't really see any use in this case. But since you didn't mention any detail in your original question I am giving the possibilities.

you cannot use IMEI number as device A does not know the IMEI number of device B. And as mentioned earlier you cannot store all the registration Ids from USER A, B, C, D.... in device A.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM