Parse在重新安装app时重新注册设备

时间:2014-11-17 20:06:19

标签: android parse-platform android-notifications

我正在尝试使用以下代码注册我的设备:

private void initParsePushMessaging() {
    Parse.initialize(this, Utils.ParseApplicationID, Utils.ParseClientKey);
    ParseInstallation parseInstallation = ParseInstallation
            .getCurrentInstallation();
    String  android_id = Secure.getString(getApplicationContext().getContentResolver(),Secure.ANDROID_ID);   

    if (ParseUser.getCurrentUser() != null) {
        parseInstallation.put("user",ParseUser.getCurrentUser());
        parseInstallation.put("UniqueId",android_id);
    }
    if (parseInstallation.getObjectId() != null)
        parseInstallation.saveInBackground(); 
    PushService.setDefaultPushCallback(this, MainActivity.class);
}

运行此代码后,我在Parse网站上看到了deviceToken。

问题 - 如果我在同一设备上卸载并重新安装该应用程序,则会在同一设备上第二次注册同一设备。

我环顾四周,发现了包含Android_ID等的提示,我把它放在我的代码中。但它还没有奏效。

任何帮助将不胜感激。

0 个答案:

没有答案
相关问题