From 4dc6318f4fcef41bdfcbab3c29b02600ae4b9c69 Mon Sep 17 00:00:00 2001 From: Atul M Date: Wed, 23 Nov 2016 00:47:49 +0530 Subject: [PATCH] Handled error in case CloudKit method fails --- Settings/Network/BKiCloudSyncHandler.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Settings/Network/BKiCloudSyncHandler.m b/Settings/Network/BKiCloudSyncHandler.m index 3635f5de8..b36e55efd 100644 --- a/Settings/Network/BKiCloudSyncHandler.m +++ b/Settings/Network/BKiCloudSyncHandler.m @@ -65,7 +65,10 @@ - (void)initSyncHandler{ CKRecordZone *zone = [[CKRecordZone alloc]initWithZoneName:BKiCloudZoneName]; [database saveRecordZone:zone completionHandler:^(CKRecordZone * _Nullable zone, NSError * _Nullable error) { - + if(error){ + //Reset shared handler so that init is called again. + sharedHandler = nil; + } }]; NSPredicate *predicate = [NSPredicate predicateWithValue:YES]; CKQuerySubscription *subscripton = [[CKQuerySubscription alloc]initWithRecordType:@"BKHost" predicate:predicate options:(CKQuerySubscriptionOptionsFiresOnRecordCreation|CKQuerySubscriptionOptionsFiresOnRecordUpdate|CKQuerySubscriptionOptionsFiresOnRecordDeletion)]; @@ -74,7 +77,10 @@ - (void)initSyncHandler{ subscripton.notificationInfo = info; [database saveSubscription:subscripton completionHandler:^(CKSubscription * _Nullable subscription, NSError * _Nullable error) { - + if(error){ + //Reset shared handler so that init is called again. + sharedHandler = nil; + } }]; }