Connect to iOS network when notified

The following code usually works, but when you try to block the connection to the SSL port (-9806) is canceled.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler { NSString *roomID = [userInfo objectForKey:@"roomId"]; if (roomID) { //tell firebase to update this conversation [self.fb updateChatRoomMessages:roomID withBlock:^(BOOL success) { /*code gets to here as I can see that with breakpoints, but before we get here we can see the SSL handshake error in console (only when phone is locked)*/ handler(UIBackgroundFetchResultNewData); }]; } else { handler(UIBackgroundFetchResultNoData); } } 

Now basically updateChatRoomMessages is trying to talk to firebase, but I assume the problem is with some kind of network connection. Is there any sort restriction known?

Any ideas?

Update - the rest of the code

 (void)updateChatRoomMessages:(NSString *)roomID withBlock:(void (^)(BOOL))completionBlock{ ChatRoomSummary *room = [[DataCollections shared] getChatRoomById:roomID]; Firebase *ref = [[Firebase alloc] initWithUrl:[NSString stringWithFormat:@"%@/chatdata/messages/%@", self.baseURL, roomID]]; [ref observeSingleEventOfType:FEventTypeValue withBlock:^(FDataSnapshot *allMsgs) { dispatch_async(dispatch_get_main_queue(), ^{ [room.messages removeAllObjects]; //clearing the list of messages so that we update it NSDictionary *dict = allMsgs.value; for(NSString *snapshot in [dict allKeys]) { NSDictionary *currentSnapshot = [dict objectForKey:snapshot]; [currentSnapshot setValue:snapshot forKey:@"messageID"]; [[DataEventListener shared] onNewMessage:currentSnapshot forRoom:room preventNotification:YES]; } [Utility notify:NOTIFY_NEW_ROOM]; [self updateBadges:nil]; if (completionBlock) { completionBlock(YES); } }); }]; } 
0
ios objective-c firebase
source share

No one has answered this question yet.

See similar questions:

7
iOS 9 ATS and Firebase REST
6
CFNetwork SSLHandshake (-9806) error using NSURLSession when application in background for uploadTask

or similar:

1264
How to check active internet connection on iOS or macOS?
386
Is it possible to disconnect the network in iOS Simulator?
364
How to handle notification when an application is in the background in Firebase
312
Best architectural approaches for building iOS network applications (REST clients)
283
How to use NSURLConnection to connect to SSL for an untrusted certificate?
158
Receive push notification when an application is in the foreground of iOS
nine
How do I get changes to the network connection notification from the iOS accessibility class?
2
React Native iOS build failing "failed to execute command: Segmentation Error: 11"
one
Is there any feedback from the application delegate when receiving a remote notification?
0
Hide UIView after network notification

All Articles