解析更新安装表中的devicetoken的错误 [英] parse error for updating devicetoken in installation table
问题描述
我正在尝试更新parse
Installation
表的deviceToken
.我正在通过rest
api用于android.但是每当我通过以下代码更新devicetoken
时
I am trying to update deviceToken
of parse
Installation
table. i am using via rest
api for android. but whenever i update my devicetoken
via following code
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
LinkedList<String> channels = new LinkedList<String>();
channels.add("Giants");
installation.put("channels",channels);
installation.put("GCMSenderId","56698194487");
installation.put("deviceToken","abcd");
installation.saveInBackground();
我遇到以下错误
由于:java.lang.IllegalArgumentException:无法修改 _Installation对象的
deviceToken
属性.
Caused by: java.lang.IllegalArgumentException: Cannot modify
deviceToken
property of an _Installation object.
我试图删除session
和installation
表,但是没有任何工作可以帮助我吗?
I tried to delete session
and installation
table but nothing works could anyone help me?
推荐答案
如果您仍要更新 deviceToken ,则可以使用"com.google.android.c2dm.intent.REGISTRATION"广播意图到您的应用,并解析android(自1.15.7 com.parse.GcmRegistrar.java开始)以选择它并更新deviceToken.
If you still want to update deviceToken, you can use "com.google.android.c2dm.intent.REGISTRATION" broadcast intent to your app and have parse android (as of 1.15.7 com.parse.GcmRegistrar.java) pick it and update the deviceToken.
当您FCM并解析服务器(从2.3.8版本开始)仍在寻找deviceToken ID来发送FCM通知时,这特别有用.
This is useful esp when you FCM and parse server (as of 2.3.8) still looking for deviceToken id to send FCM notification.
Intent i = new Intent();
i.setAction("com.google.android.c2dm.intent.REGISTRATION");
i.putExtra("registration_id", FirebaseInstanceId.getInstance().getToken());
sendBroadcast(i);
除了com.google.firebase.MESSAGING_EVENT和INSTANCE_ID_EVENT意向过滤器之外,请确保您在android清单中有此标记
Make sure you have this in android manifest, apart from com.google.firebase.MESSAGING_EVENT and INSTANCE_ID_EVENT intent filters
<receiver android:name="com.parse.ParseBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.my.package" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
这篇关于解析更新安装表中的devicetoken的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!