You can try to implement the behavior you are looking for using push notifications with available content, which gives you some time to download content in the background (more info here ), to do this, your payload should be structured as
{ "aps" : { "content-available" : 1 }, "data-id" : 1234 }
Then do the following method to load the content or in your case do something with your web socket
- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
This method should only be used to update any state of your application or to download some data, Apple does not recommend using it so that your socket is always alive, and Iām sure that it will ultimately reject your application if you use your the socket is always alive.
source share