如何使用pushwoosh android原生SDK获取regID
我正在使用PushWoosh android原生SDK进行推送通知。我想在成功注册时重用GCM提供的regId。如何使用android原生SDK获取此regID?当您从GCM注册中获取regID时,请将其存储在如何使用pushwoosh android原生SDK获取regID,android,notifications,pushwoosh,Android,Notifications,Pushwoosh,我正在使用PushWoosh android原生SDK进行推送通知。我想在成功注册时重用GCM提供的regId。如何使用android原生SDK获取此regID?当您从GCM注册中获取regID时,请将其存储在SharedReferences中,以便稍后访问 储存 GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(getApplicationContext()); String regId = gcm.register(ID)
SharedReferences
中,以便稍后访问
储存
GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
String regId = gcm.register(ID);
SharedPreferences shp = getApplicationContext().getSharedPreferences("PrefKey",
getApplicationContext().MODE_PRIVATE);
shp.edit().putString("RegId",regId).commit();
得到它
SharedPreferences shp = getApplicationContext().getSharedPreferences("PrefKey",
getApplicationContext().MODE_PRIVATE);
if (shp != null && shp.contains("RegId"))
regId = shp.getString("RegId", null);
gcm.register(ID)中的ID参数需要字符串数组。ID的具体值应该是什么?您可以传入一个字符串数组,但只需在Google API控制台中提供您的项目ID(URL.ex:末尾的数字)