ios - itune - Las suscripciones de CloudKit para CKSubscriptionOptionsFiresOnRecordUpdate no funcionan
dar de baja apple music (0)
Creé una suscripción para crear y actualizar. La creación siempre funciona perfecta y recibo notificaciones automáticas de otros dispositivos. La actualización va a iCloud, puede verlos allí, pero las notificaciones automáticas no se envían al dispositivo.
- (void)subscribeWithType:(NSString*)type completionHandler:(void(^)(CKSubscription *))completionHandler
{
if (self.enabled == NO || _available == NO || _reachability.currentReachabilityStatus != ReachableViaWiFi)
{
if (completionHandler)
{
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(nil);
});
}
return;
}
NSPredicate *truePredicate = [NSPredicate predicateWithValue:YES];
CKSubscriptionOptions options = CKSubscriptionOptionsFiresOnRecordCreation | CKSubscriptionOptionsFiresOnRecordUpdate;
CKSubscription *subscription = [[CKSubscription alloc] initWithRecordType:type
predicate:truePredicate
subscriptionID:[CTUtils GetUUID]
options:options];
CKNotificationInfo *notification = [[CKNotificationInfo alloc] init];
notification.shouldSendContentAvailable = YES;
notification.alertLocalizationKey = @"";
notification.shouldBadge = NO;
subscription.notificationInfo = notification;
CKModifySubscriptionsOperation *operation = [[CKModifySubscriptionsOperation alloc] initWithSubscriptionsToSave:@[subscription] subscriptionIDsToDelete:nil];
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
__block CKSubscription *resultSubscription = nil;
operation.modifySubscriptionsCompletionBlock = ^(NSArray *savedSubscriptions, NSArray *deletedSubscriptionIDs, NSError *operationError) {
if (operationError)
{
if (iCloudLog)
{
NSLog(@"create %@ subscriptions error : %@", type, operationError);
}
}
else
{
resultSubscription = savedSubscriptions.firstObject;
if (iCloudLog)
{
NSLog(@"created subscription for %@: %@", type, savedSubscriptions);
}
}
dispatch_semaphore_signal(semapthore);
};
dispatch_async(dispatch_get_main_queue(), ^{
[self.privateDatabase addOperation:operation];
});
dispatch_time_t time = DISPATCH_TIME_FOREVER;
dispatch_semaphore_wait(semapthore, time);
if (completionHandler)
{
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(resultSubscription);
});
}
}
¿Alguien ve aquí error o por qué no implementó la notificación push para actualizar?