我想在我的应用程序中实现推送通知。我想知道,在启用谷歌云消息传递API后,我们如何在Android中获取推送通知的设备令牌。我们如何获得特定设备的设备令牌?
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);
}
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.