w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
"at least one ID field (installationId,deviceToken) must be specified in this operation" parse

I'm definitely convinced that this is caused by a parse bug. Same thing is said by a lot of unresolved bug reports I found at Parse.com. I'm currently working with Parse 1.5.1: The thing that I've seen is that without deviceToken the push aren't sent, and without the uniqueId we get the runtime error here above. If I send the UniqueId immediately after the registration, a row without deviceToken is saved. The solution for me, tested on Nexus 5, Nexus 4 and Sony xperia E: In your Application class onCreate()

    Parse.initialize(this, PARSE_APP_KEY_VALUE,
PARSE_CLIENT_KEY_VALUE);
    PushService.setDefaultPushCallback(getApplicationContext(),
MainActivity.class);
    final ParseInstallation installation =
ParseInstallation.getCurrentInstallation();
    final String  androidId =
Settings.Secure.getString(getApplicationContext().getContentResolver(),
Settings.Secure.ANDROID_ID);
        // Post the uniqueId delayed
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    installation.put("UniqueId",
androidId);
                                    installation.saveInBackground(new
SaveCallback() {
                                        @Override
                                        public void done(ParseException e)
{
                                            // Saved!
                                        }
                                    });
                                }
                            }, 10000
        );

Working this way, I'm able to save correct rows (with uniqueId and deviceToken), and to send push notification! Cheers!





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.