美文网首页
控制 App在后台运行的方法

控制 App在后台运行的方法

作者: 小苗晓雪 | 来源:发表于2017-06-06 13:54 被阅读158次

UIApplication类提供了2方法用来让 App 在后台执行,除了苹果允许的音乐类等 App 允许在后台长时间执行之外 , 其他的 App在 iOS7之前默认是10分钟, iOS7之后默认是3分钟;

- (UIBackgroundTaskIdentifier)beginBackgroundTask
WithExpirationHandler:(void(^ __nullable)(void))handler
NS_AVAILABLE_IOS(4_0) NS_REQUIRES_SUPER;
- (UIBackgroundTaskIdentifier)beginBackgroundTask
WithName:(nullable NSString *)taskName 
expirationHandler:(void(^ __nullable)(void))handler 
NS_AVAILABLE_IOS(7_0)
NS_REQUIRES_SUPER;
- (void)endBackgroundTask:(UIBackgroundTaskIdentifier)identifier
 NS_AVAILABLE_IOS(4_0) NS_REQUIRES_SUPER;

愿编程让这个世界更美好

相关文章

网友评论

      本文标题:控制 App在后台运行的方法

      本文链接:https://www.haomeiwen.com/subject/kzbgfxtx.html