我想要什么不叫:didReceiveRemoteNotification当CloudKit记录添加
我希望我的iOS应用程序来执行一旦CloudKit记录添加一个动作。
我做了什么:
我跟着苹果的info做到这一点。
问题:
application:didReceiveRemoteNotification
永远不会被调用。
我试图解决这个问题:
我已经成功地建立了一个订阅时加入CloudKit记录得到通知。我确认这与application:didRegisterForRemoteNotificationsWithDeviceToken
。
我也证实了这个记录确实是创建的。
我可以使用CKQueryOperation
获取记录。
我也试过用application:didReceiveRemoteNotification:fetchCompletionHandler
,但是这个方法也没有被调用。
我搜索了Apple Developer Forums以及StackOverflow,但没有找到解决我的问题的方法。
我该怎么办?
代码来创建订阅:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"TRUEPREDICATE"];
CKSubscription *subscription = [[CKSubscription alloc] initWithRecordType:@"command" predicate:predicate options:CKSubscriptionOptionsFiresOnRecordCreation];
CKNotificationInfo *notificationInfo = [CKNotificationInfo new];
notificationInfo.alertLocalizationKey = @"New command.";
notificationInfo.shouldBadge = YES;
subscription.notificationInfo = notificationInfo;
[VMKGlobalVariables.GLOBAL_appDelegate.privateDatabase saveSubscription:subscription
completionHandler:^(CKSubscription *subscription, NSError *error) {
if (error)
{
// insert error handling
}
else
{
DDLogVerbose(@"Added command subscription successfully.");
}
}
];
远程通知不适用于模拟器。您需要使用真实的设备。是这样吗? – Starlord
谢谢。是的,我使用的是iPhone 6s。 – vomako
更新您的问题,提供有关订阅和添加记录的更多相关信息。并确认您正在讨论在一台设备上添加记录并在另一台设备上获取通知。您不会在用于添加记录的相同设备上收到通知。 – rmaddy