When IOS does not enable the telephone service, it can respond to the server's push messages to receive the server's push messages.
- When performing Instant Messaging (based on the xmpp framework), you can press the Home Key to return to the desktop. When you return to the desktop, this is the pending state of your program,
- It is equivalent that your program is dead, and all processes of the program are in sleep state. All the operations you perform at this time are useless, and the mobile phone will never receive any message push from you, the reason is that the mobile phone is in sleep state. At this time, You must wake it up to receive the messages you pushed. At that time, my application opened the telephone service, because the telephone service always keeps the mobile phone awake, and all the calls can be received when your mobile phone is in any status. This is the telephone service. I used such a service, so that my program could not be sleep. When I shelved the AppStore, it was rejected by Apple. All of my brains came up with a solution. is the added telephone service. When I add such a service, the Apple store will not allow the app store to be mounted. So I tried another method.
- Is the solution:
- In AppDelegate. Add the code above.
1-(void) applicationDidEnterBackground :( UIApplication *) application 2 {3 [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0]; // enter the foreground to cancel the application message icon 4 5 6 UIApplication * app = [UIApplication sharedApplication]; 7 8 _ block UIBackgroundTaskIdentifier bgTask; 9 10 bgTask = [app beginBackgroundTaskWithExpirationHandler: ^ {11 12 dispatch_async (dispatch_get_main_queue (), ^ {13 14 if (bgTask! = UIBackgroundTaskInvalid) 15 16 {17 18 bgTask = UIBackgroundTaskInvalid; 19 20} 21 22}); 23 24}]; 25 26 dispatch_async (dispatch_get_global_queue (queue, 0 ), ^ {27 28 dispatch_async (dispatch_get_main_queue (), ^ {29 30 if (bgTask! = UIBackgroundTaskInvalid) 31 32 {33 34 bgTask = UIBackgroundTaskInvalid; 35 36} 37 38}); 39 40}); 41 42}
Well, this is my solution. Without the system's telephone service, you can wake up the program and the background cannot push messages ..
Thank you. We can learn more and make more progress in the future ..
PS: I don't know what other methods are. If I have other methods, I can leave a message for you. Let's discuss it together ..