在我的应用程序中,无论设备如何,我都想向特定用户发送通知。用户可以从任何设备登录应用程序。
这是我第一次使用 GCM。我阅读了文档,它说当设备向 GCM 服务器注册时,设备会将该唯一 ID 发送到服务器,然后保存该值以发送消息。
那么当他从不同设备登录应用程序时如何向特定用户发送通知?
在我的应用程序中,无论设备如何,我都想向特定用户发送通知。用户可以从任何设备登录应用程序。
这是我第一次使用 GCM。我阅读了文档,它说当设备向 GCM 服务器注册时,设备会将该唯一 ID 发送到服务器,然后保存该值以发送消息。
那么当他从不同设备登录应用程序时如何向特定用户发送通知?
This unique ID (aka registration ID) is unique given an app/device, so if this user logs to GCM services on another device it will generate another registration ID.
An ID issued by the GCM servers to the Android application that allows it to receive messages. Once the Android application has the registration ID, it sends it to the 3rd-party application server, which uses it to identify each device that has registered to receive messages for a given Android application. In other words, a registration ID is tied to a particular Android application running on a particular device.
When you say log I think you are reffering to your server, right?
I ask it because GCM services requires a Google account if your app is targetting pre 4 API versions.
A Google account is not a requirement on devices running Android 4.0.4 or higher.
If GCM detects a google account on the device it can acces to the service. If GCM does not detect the account it returns an ACCOUNT_MISSING error.
So it could happen to acces the GCM services with a google account that is not yours if you are using another device which was previously registered with a Google account.
But if the important account is one managed by your server then I think it does not really matter.
Updated:
You will have to send the notification to all registrationID belonging to the user connected to your server. You can not know which device is the user currently using if you mantain more than one at your server.