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();
I got following error
Caused by: java.lang.IllegalArgumentException: Cannot modify
deviceToken
property of an _Installation object.
I tried to delete session
and installation
table but nothing works could anyone help me?
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.
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);
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
field is read only
in Installation
so you can't modify or update them.
Parse.com
android
docs
deviceToken: The token used by GCM to keep track of registration ID.
On iOS devices, this is the Apple generated token (readonly).
If anyone still facing same problem. Please find solution here.
link: https://drive.google.com/drive/folders/0B04Quls_ltDDNnVrRE55Yk9sb2M?usp=sharing
Extract attached file and add it as a module in your project.
Mention this module file in settings.gradle.
Add this statements in your app moduel in build.gradle, like
//compile 'com.parse.bolts:bolts-tasks:1.3.0' //Comment it if available
compile project(':Parse-release') //Use this one.
- Clean build and Build once.
Note: I hope this custom library will help you to update deviceToken, since in this library deviceToken is editable rest everything is same.