Evan
Evan

Reputation: 202

Parse Won't Save Installation, Error: badge must be a non-negative integer

My problem seems to be almost identical to this one, which was never solved:

https://www.parse.com/questions/installation-not-created

It started when I deleted all the installations from the Parse data browser (bad idea, I know that now). The problem now is that it won't save any new installations from one of my (real) test devices, presumably because of this confusing error:

Error: badge must be a non-negative integer: -3 (Code: 111, Version: 1.2.20)

This occurs on a fresh installation when I have yet to do anything to the badge number. To make it even more complicated, Parse will save installations from other (real) devices and the simulator. For reference, this is how I am attempting to save installations in my AppDelegate.m:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    // Store the deviceToken in the current installation and save it to Parse.
    PFInstallation *currentInstallation = [PFInstallation currentInstallation];
    [currentInstallation setDeviceTokenFromData:deviceToken];
    [currentInstallation saveInBackground];
}

Any ideas?

Upvotes: 3

Views: 497

Answers (1)

Evan
Evan

Reputation: 202

I still don't know why this error occurred, but the solution seemed to be inserting the following line of code and then removing it after installation:

[[PFInstallation currentInstallation] setBadge:0];

Upvotes: 2

Related Questions