ParseInstallation类将deviceToken返回为null,并且在Parse.com安装表中,安装将保存为空的deviceToken。
使用
Android应用程序类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
}
});
}
答案 0 :(得分:0)
你需要确保在包名中包含你的构建风味,我最近遇到了这个问题并且在我添加之前没有意识到很长时间。
即com.packname.flavor {debug,release等}
答案 1 :(得分:-2)
发现错误。我必须在安装类上更改Parse权限(允许添加字段),然后显示“channels”字段,并且还保存了deviceToken。
更新:
您可以在应用设置上确认: 核心>数据> _安装>安全性(工具栏上的按钮)
默认情况下,它有权创建新字段但我已更改它。