i want to implement push notification in my application.i want to know,how we get the device token for push notification in android after enabling the google cloud messaging API.How can we get a device token for a particular device??
try {
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
Log.i(TAG, "GCM Registration Token: " + token);
}catch (Exception e) {
Log.d(TAG, "Failed to complete token refresh", e);
}