getCurrentInstallation().saveInBackground() Adding extra ID string in front
When using ParseInstallation.getCurrentInstallation().saveInBackground(); it is adding in "|ID}#|:" to the device Token. This is causing issues with pushAdapters because it sends that extra bit of string when trying to use a third party push service. like pushwoosh.
For example
|ID|1|:es3c-xxxxxxxxxxxxx
I assume its the ID stored in mongodb. Can we get this extra bit removed?
when I stepped through the code it seemed to be the registration token that's been given by GCM, not Parse
if you set a breakpoint in GcmRegistrar.handleRegistrationIntentAsync() (which handles the intent) you should be able to see it there
The only way to get the push to work is remove |ID|#|. So should I not use getCurrentInstallation? Or should that function be handling this? Having to go into parse to remove that string for every new installation would be a pain.
This is causing issues with Amazon SNS for us, the token has an invalid format and is therefore rejected.
Is the GCM token generated with a different structure now that Firebase has taken over?
Ok it seems GcmRegistrar receives two tokens from GCM when currentInstallation.saveInBackground() is called the first time.
The first looks correct:
com.parse.GcmRegistrar: Received deviceToken <APA91bEUQe7Hss2yjK11gq1E5UHCTYJyA2nWEpDArJqalOCR_lbp0PvSWz8jRD4NjEAvXgWsHdokq0KyTuZLFYZv5xgg1Cry7fz3RsMrFSXOxoLPoZZjKEs1gaq_pBIKruDaDdtd> from GCM
Then immediately after this is logged with the ID prefix:
com.parse.GcmRegistrar: Received deviceToken <|ID|1|:ei7dEQ3kHI4:APA91bFiJDFr-FqhevPOiKvBaZNk4ftA5sHmVx4Erbxuvf_2JL8-uoXvc1GRUFpKCtuMClHKgeM2gW1xfTeejYG2aiIGLLBpgGNjPg_cmFUAFiC4lk5Rvp> from GCM.
If anyone has a solution or temporary work around for this, that would help a lot. At this point I would have to create something to constantly parse out all the extra prefix stuff.
Hi,
dealing with the same problem. @jackdewhurst : you're right and the 2 GCM id is different from the first one (after the |ID|1|:...: pattern.
I tried to modify the PushAdapterUtils.js (server side) using
installation.deviceToken.replace(/\|ID\|1\|:[^:.]*:/,"");
but with no luck for now.
I encounter this issue just after moving to play-services: 9+ if it helps.
For now we've written a job to trim tokens up to the first colon server side.
So if a token begins with |ID|1|: we trim the prefix and re-save the installation object. Devices with trimmed tokens seem to receive notifications ok for now.
Not ideal though.
@devcheetah
My current work around is have a new class that extends ParseInstallation in the same package ( so that i can access the protected member of ParseIntallation) and have a helper function to read the current installation and modifiy it if it is in wrong format
however, since we don't know when and we don't have callback when the GCM token is received (it is in the background), i call this helper everytime in my activity onCreate, it's not ideal solution, but at least I only save the installation when the format is wrong, hence it's not that bad...
Before I have this "hack" solution, I tried manually get the GCM token, but parse won't save though
Any update on this guys?
For the time being I made cloud code beforeSave to remove this and is working for now.
Parse.Cloud.beforeSave(Parse.Installation, function(request, response){ var id = request.object.get("deviceToken").replace("|ID|1|:",""); request.object.set("deviceToken",id); response.success(); });
We have had the same problem, but in our case was a conflict with the gms plugin and firebase lib, so we removed:
apply plugin: 'com.google.gms.google-services'
and
compile 'com.google.firebase:firebase-core:9.0.2'
ID's are now correct and push notifications are working again
I have the same issue with:
- Parse SDK 1.13.1
- Play Services GCM 9.2.0
- Google Services 3.0.0
How can I solve it?
Thank you!
Yep +1 on this! @devcheetah Are you still using your cloud beforeSave trigger?
I am using the beforeSave still.
Thanks, @FireZenk fix worked for me.
Looks like
compile 'com.google.firebase:firebase-core:9.0.2'
Fix the issue
👍
I have the same issue, but if I remove apply plugin: 'com.google.gms.google-services' the screen trackers are down ...
I used:
compile 'com.google.android.gms:play-services-gcm:9.2.1'
compile 'com.google.android.gms:play-services-analytics:9.2.1'
apply plugin: 'com.google.gms.google-services'
Any ideas how I can solve this issue?
I am adding the relevant parts that works for me:
Root-level build.gradle
dependencies {
.....
classpath 'com.google.gms:google-services:3.0.0'
.....
}
Module build.gradle
dependencies {
compile 'com.google.android.gms:play-services-gcm:9.2.0'
}
I didn't need the apply plugin: 'com.google.gms.google-services' here.
Manifest.xml
<!--GCM Sender ID was provided by the GCM Project information on developerconsole.google.com-->
<meta-data android:name="com.parse.push.gcm_sender_id"
android:value="id:YourGCMSenderID" />
We can close by upgrading to a later version of GCM right?