iOS后台任务
来源:互联网 发布:文明5 mac版 编辑:程序博客网 时间:2024/04/29 16:16
iOS后台任务
ios后台运行分方式有三种
- 1 永远运行
- 2 短暂运行
- 3 立即挂起
后台永远运行分为这几种情况
- 播放音频文件(playing audio
获取定位更新(getting location updates)
杂志app中下载新的期刊(downloading new issues for newsstand apps)
- VoIP 呼叫(handing VoIP calls)
实现方式
1 适配Info.plist 文件
- 在
info.plist
中的Required background modes
key 类型为NSArray
- 在其中添加Value 为
App registers for location updates
设定后台定位 - 在其中添加Valur 为
App plays audio or streams audio/video using AirPlay
设定后台音乐播放
- 在
2 如果是定位,申请定位权限。 播放音乐申请后台播放权限。具体看具体代码
后台短暂运行
App 进入后台默认情况会立即挂起,不会再运行情况。 后台短暂运行App 进入后台,系统会让其在运行一段时间在挂起。
实现方式
// 接收进入后台通知 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backgroundCleanDisk) name:UIApplicationDidEnterBackgroundNotification object:nil];// 后台处理- (void)backgroundCleanDisk { UIApplication* app = [UIApplication sharedApplication]; __block UIBackgroundTaskIdentifier bgTask; bgTask = [app beginBackgroundTaskWithExpirationHandler:^{ [app endBackgroundTask:bgTask];s bgTask = UIBackgroundTaskInvalid; }]; }
1 0
- iOS后台网络任务
- IOS的后台任务
- iOS后台网络任务
- IOS后台多任务
- ios 无限后台任务
- iOS 无限后台任务
- iOS 后台任务
- ios后台任务
- iOS后台任务
- IOS的后台任务
- iOS后台网络任务
- IOS的后台任务
- iOS无限后台任务
- iOS后台任务
- IOS的后台任务
- iOS后台任务
- iOS的后台任务
- iOS进入后台长时间运行后台任务
- iOS中的BOOL和bool
- 开发云服务器
- 海之归墟
- dubbo 的monitor监控中心 配置过程_linux
- 金融信息交换协议(FIX)——采用多播技术的FIX会话
- iOS后台任务
- Activity和Fragment生命周期
- Unity3D性能优化
- .net中创建table手动添加列
- 爱我所爱——守护这片情
- 随便谈谈1
- 屏幕适配之内联函数
- 那年那岁那时那你
- 采用多播传送FIX行情数据的推荐方案