14

I am using the parse for push-notification in our application but some problem in registration of device, the error is shown below. There are also problem ,when we send push notification to the device more than one notification received by the device. although we have also upgraded the parse library to the Parse 1.4.1.Please help me,thanks in advance.

Error is shown when app first time installed:

04-14 14:00:40.004: E/LOG(26045): Socket event: onConnect 
04-14 14:00:41.874: E/ParseCommandCache(26045): Failed to run command.
04-14 14:00:41.874: E/ParseCommandCache(26045): com.parse.ParseException: at least one ID field (installationId,deviceToken) must be specified in this operation
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.ParseCommand$2.then(ParseCommand.java:348)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$10.run(Task.java:452)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$1.execute(Task.java:68)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.completeImmediately(Task.java:448)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.continueWith(Task.java:322)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.continueWith(Task.java:333)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$8.then(Task.java:385)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$8.then(Task.java:377)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$11.run(Task.java:485)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$1.execute(Task.java:68)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.completeAfterTask(Task.java:481)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.access$300(Task.java:18)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$7.then(Task.java:350)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$7.then(Task.java:347)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.runContinuations(Task.java:514)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.access$700(Task.java:18)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:569)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$TaskCompletionSource.setResult(Task.java:603)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$11$1.then(Task.java:497)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$11$1.then(Task.java:489)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$10.run(Task.java:452)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$1.execute(Task.java:68)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.completeImmediately(Task.java:448)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.access$200(Task.java:18)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$6.then(Task.java:315)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$6.then(Task.java:312)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.runContinuations(Task.java:514)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.access$700(Task.java:18)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:569)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$TaskCompletionSource.setResult(Task.java:603)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$11$1.then(Task.java:497)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$11$1.then(Task.java:489)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$10.run(Task.java:452)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$1.execute(Task.java:68)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.completeImmediately(Task.java:448)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.continueWith(Task.java:322)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.continueWith(Task.java:333)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$11.run(Task.java:489)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$1.execute(Task.java:68)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.completeAfterTask(Task.java:481)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.access$300(Task.java:18)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$7.then(Task.java:350)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$7.then(Task.java:347)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.runContinuations(Task.java:514)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task.access$700(Task.java:18)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$TaskCompletionSource.trySetResult(Task.java:569)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$TaskCompletionSource.setResult(Task.java:603)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at com.parse.Task$3.run(Task.java:228)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-14 14:00:41.874: E/ParseCommandCache(26045):     at java.lang.Thread.run(Thread.java:841)

Updated code

    Parse.initialize(this, Constant.PARSE_APP_ID, Constant.PARSE_CLIENT_KEY);
    ParseACL defaultACL = new ParseACL();
    defaultACL.setPublicReadAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);
    PushService.setDefaultPushCallback(this, MainActivity.class);
    ParseInstallation.getCurrentInstallation().getInstallationId();
    ParseInstallation.getCurrentInstallation().saveInBackground();

This is the code which I used for the registration on parse.com

   PushService.subscribe(this, "name",Detail.class);

This is the code which i used for the registration of the chanels

Mayur Raval
  • 3,250
  • 6
  • 34
  • 57

4 Answers4

8

Same problem here.
This looked like a race condition to me, so I tried putting setDefaultPushCallback in a new Callback like this:

ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback()
{
    @Override
    public void done(ParseException e)
    {
        PushService.setDefaultPushCallback(ParseApplication.this, ParseStarterProjectActivity.class);
    }
});

I haven't had a crash yet (although it hasn't been very long). I hope this helps.

Spidy
  • 1,137
  • 3
  • 28
  • 48
ameron32
  • 136
  • 1
  • 2
4

We had a similar issue:

We had to move the: PushService.setDefaultPushCallback(this, MainActivity.class);

Into the MainActivity#onCreate, we tried calling this in our application class but that cashed.

Parse are really unhelpful on this matter, hopefully one of them and provide some insight.

Chris.Jenkins
  • 13,051
  • 4
  • 60
  • 61
3

I had the same Exception doing something similar. I save an ACL to the installation when the user logs in to the app with Facebook. (When doing this, the installation doesn't exist at the server yet.)

To get rid of the Exception, I used saveEventually() instead of saveInBackground(). This made the Exception go away, and the installation is saved to the server properly with it's ACL.

Albert Vila Calvo
  • 15,298
  • 6
  • 62
  • 73
  • It's ok to check for internet connection and based on the result, to use `saveEventually` or `saveInBackground`? – Iulian Onofrei Feb 23 '15 at 13:10
  • 1
    @IulianOnofrei Of course you can, but I believe that one of the main reasons for using Parse is to forget about this things. If you want to do so, try using `saveInBackground()` with a `SaveCallback() `and, if it fails (i.e. `ParseException` is not null), then fire a `saveEventually()` inside it. That said, I always use `saveEventually()` except for things that need to be saved immediately. – Albert Vila Calvo Feb 23 '15 at 14:46
0

You need to create a class in your project that extends from Application

public class YourApplicationName extends Application  {


  @Override
   public void onCreate() {
    super.onCreate();
    Parse.initialize(this, "", "");
  }
}

Fill the "" with your Parse info

Also add it to the manifest

schnatterer
  • 7,525
  • 7
  • 61
  • 80