UIApplication beginBackgroundTaskWithExpirationHandler question
This looks like good sample code where you can see the usage of blocks ^{} together with applicationDidEnterBackground: http://iphonesdkdev.blogspot.com/2010/04/local-push-notification-sample-code-os.html
cpprulez
Updated on June 07, 2022Comments
-
cpprulez about 2 years
guys :) I have an iOS alarm app, which uses UILocalNotification-s to schedule the user defined alarms if the app enters background. Since this (in my implementation) can be a relatively long process, I need to make sure that the registering of the notifications is completed before the app goes inactive. I read that there is a method in UIApplication: beginBackgroundTaskWithExpirationHandler, which asks iOS for more time, so that it can complete its tasks, but I have no idea how to use it. These (void(^)(void)) parameters scare me :). I know it's too much to ask, but... if I have a method [self registerLocalNotifications], which registeres all local notifications, can you please point me how to make sure the method finishes before the app goes to background. Huge thanks!
-
cpprulez over 13 yearsThank you! I'll check it out :)