0

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?

Philip Sopher
  • 627
  • 2
  • 8
  • 19
  • Try instead `PFPush subscribeToChannelInBackground:`. You may also need to delete the app and reinstall it – Wain Jan 11 '16 at 17:38
  • @Wain what do you mean by deleting the app and reinstalling it? Deleting it in Parse? – Philip Sopher Jan 11 '16 at 17:40
  • @Wain thanks for the help, but neither of those worked! Any other suggestions? – Philip Sopher Jan 11 '16 at 17:54
  • Is that the only thing that isn't working? No other ideas come to mind immediately... – Wain Jan 11 '16 at 19:06
  • @Wain I added this question too: http://stackoverflow.com/questions/34728888/mobileprovision-file-is-not-added-to-keychain-access-when-double-clicked-for-pa It's the only thing I could think might be wrong. Thanks again for helping – Philip Sopher Jan 11 '16 at 19:08
  • I just resolved the issue in the post about .mobileprovision files, but it didn't solve this issue. Any help is greatly appreciated – Philip Sopher Jan 11 '16 at 19:40

1 Answers1

0

This is so frustrating. All I had to do was log out of my Parse account and then log back into it. And voila! The channels were there!

Philip Sopher
  • 627
  • 2
  • 8
  • 19