UIApplication beginBackgroundTaskWithExpirationHandler question

guys :) I have an app for iOS alarms that uses UILocalNotification-s to schedule custom alarms if the app enters the background. Since this (in my implementation) can be a relatively long process, I need to make sure that notification registration is complete before the application is inactive. I read that there is a method in UIApplication: beginBackgroundTaskWithExpirationHandler that asks iOS more time so that it can perform its tasks, but I have no idea how to use it. These (void (^) (void)) parameters scare me :). I know this is too much to ask, but ... if I have a [self registerLocalNotifications] method that logs all local notifications, can you tell me how to make sure the method ends beforehow the application will go to the background. Thank you so much!

+3
source share
1 answer

This looks like a good code example where you can see the use of ^ {} blocks along with applicationDidEnterBackground: http://iphonesdkdev.blogspot.com/2010/04/local-push-notification-sample-code-os.html

+6
source

Source: https://habr.com/ru/post/1791262/


All Articles