I am an objective c coder trying to use push notifications in parse.
I added the Parse setApplicationID and Client Key in the didFinishLaunchingWithOptions section of the appDelegate.m file. Then I added these two methods:
- (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.badge = 0;
NSArray *channels = [NSArray arrayWithObjects:@"global", [DataSource sharedInstance].userProfile.userID, nil];
[currentInstallation addObjectsFromArray:channels forKey:@"channels"];
[currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}
Whenever the currentInstallation.badge number changes, the badge number on the app responds, and when I break point the code, it shows that channels have been added to currentInstallation.
The problem is that the current installation isn't saved in the Core Installation objects section of the Parse database. The channels that I added to currentInstallation do not appear after saveInBackground has run.
In debugging the issue, I deleted the row in the Core Installation database that corresponds to the device that I'm using for testing (which was the only object in the Core Installation database). When I rerun the code, nothing gets added.
One more piece of information is that I'm pretty sure I did all the set up stuff correctly because after setting everything up, I was able to receive test push notifications on my device. The problem is that I'm not able to programatically change the channels that my test device is subscribed to on the Core Installation database.
So basically my question is: How do I write items into the Core Installation database using PFInstallation saveInBackground? What am I doing wrong?
Thanks for the help! I really appreciate it!
Edit One more issue, now, is that I can't add the device that I'm testing push notifications back into my Core Installations objects database, so I'm still at 0 objects in the database. Any recommendations on how I get it back?