Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用pushwoosh android原生SDK获取regID_Android_Notifications_Pushwoosh - Fatal编程技术网

如何使用pushwoosh android原生SDK获取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)

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

当您从GCM注册中获取regID时,请将其存储在
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:末尾的数字)