Android 和 Parse.com 上的 deviceToken 始终为空

deviceToken is always null on Android with Parse.com

ParseInstallation class returns deviceToken 为 null 并且在 Parse.com 安装 table 安装中保存为空 deviceToken。

使用

Android 应用程序 class onCreate:

@Override
public void onCreate() {
    super.onCreate();

    ParseCrashReporting.enable(getApplicationContext());
    Parse.initialize(this, "xx", "xx");
    ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
        @Override
        public void done(ParseException e) {
            String deviceToken = (String) ParseInstallation.getCurrentInstallation().get("deviceToken");

            Log.d("my_app","DEVICE TOKEN: " + deviceToken);  // --> returns null string
        }
    });
 }

发现错误。我必须在安装 class 上更改解析权限(允许添加字段),然后显示 'channels' 字段并保存 deviceToken。

更新:

您可以在应用设置中确认: 核心 > 数据 > _安装 > 安全(工具栏上的按钮)

默认情况下,它可以创建新字段,但我更改了它。

您需要确保在包名称中也包含您的构建风格,我最近遇到了这个问题,很长一段时间才意识到这一点,直到我添加了它。

即com.packname.flavor{调试、发布等}