I am stucked with the process of creating a push notification using Google's cloud notifications.
What I am working on is the part where I am supposed to get the device id of the device so that I can use that device id later on, when I need to send a push notification.
So I have this code:
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals(""))
{
GCMRegistrar.register(this, SENDER_ID);
}
else
{
//Log.v(TAG, "Already registered");
}
and I thought that this line
final String regId = GCMRegistrar.getRegistrationId(this);
Was going to get me the device id so I can store that somewhere. But I think I am way off track in how this is actually meant to work. Could someone please explain to me how I can get the unique id of the device so I can store it for further push notifications?
The 'unique id' of the device is actually a unique id based on device and app installation. The GCMRegistrar.getRegistrationId(context)
will give you that unique ID. If you are looking to get it after it registers, it is passed into the onRegistered method of the GCMIntentService that you have to override to make it work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With