我正在使用PushWoosh android native SDK进行推送通知。我想在成功注册后重用GCM提供的regId。如何使用android native SDK获得此regID?

最佳答案

从GCM注册获得regID时,请将其存储在SharedPreferences中以供以后使用。

储存

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);

关于android - 如何使用pushwoosh android native SDK获取regID,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32102233/

10-10 08:47