I have an app that I'm building, and I'm trying to keep track of a subscription using Cloudkit. I have a RecordType called Notifications with one field of type String called NotificationText. For some reason, when I add a new record, the app does not receive it. Here's what I have done so far:
- Registered for Cloudkit in the "Capabilities" section of the app.
- Added the Required background modes key to the info.plist file for remote-notifications
Saved the Subscription to the database using:
CKSubscription *subscription = [[CKSubscription alloc] initWithRecordType:@"Notifications" predicate:[NSPredicate predicateWithValue:YES] options:CKSubscriptionOptionsFiresOnRecordCreation]; CKNotificationInfo *notificationInfo = [CKNotificationInfo new]; notificationInfo.alertLocalizationKey = @"NotificationText"; notificationInfo.shouldBadge = YES; notificationInfo.soundName = @""; subscription.notificationInfo = notificationInfo; [publicDB saveSubscription:subscription completionHandler:^(CKSubscription *subscription, NSError *error) { if (error) [self handleError:error]; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"sub"]; } ];Requested permission from the user to send push notifications using:
UIApplication *application = [UIApplication sharedApplication]; UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert categories:nil]; [application registerUserNotificationSettings:notificationSettings]; [application registerForRemoteNotifications];Implemented the
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(non null NSDictionary *)userInfo fetchCompletionHandler:(non null void (^)(UIBackgroundFetchResult))completionHandler;in the AppDelegate.m file.
Now I go into the Cloudkit Dashboard and create a new record of RecordType Notifications, and nothing happens. Am I doing something wrong? Am I missing something?