iOS_Pass iOS10适配:权限访问、MiPush小米推送(更新中)
来源:互联网 发布:网络语byd是什么意思 编辑:程序博客网 时间:2024/05/29 04:34
iOS10官方文档原版
翻译
Pass_1
iOS10 相册,相机内的提示文字变成了英文,比如,取消(cancel),完成(complete)等,解决方法
在项目的info.plist里面添加Localized resources can be mixed
值为 YES
Pass_2
iOS10 权限设置,相机、相册、地理位置、蓝牙等获取权限崩溃,解决方法
在项目的info.plist里边添加相关的权限key及其提示语言如图所示,左侧是权限key,右侧填写需要的提示语言。
Pass_3
iOS10 MiPush 小米推送适配
截止2016-09-18 18:03发文小米推送没有针对iOS10作出更新,(极光更新了),只能手动适配
如下:
*1,在工程中添加UserNotifications.framework
![这里写图片描述](http://img.blog.csdn.net/20160918181012196)
*2,在AppDelegate中引入头文件,并遵守协议
#import <UserNotifications/UserNotifications.h>@interface AppDelegate () <MiPushSDKDelegate, UNUserNotificationCenterDelegate>
3,添加新的注册代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) { UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound) completionHandler:^(BOOL granted, NSError * _Nullable error) { if (granted) { //点击允许 NSLog(@"注册通知成功"); [center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) { NSLog(@"%@", settings); }]; } else { //点击不允许 NSLog(@"注册通知失败"); } }]; [MiPushSDK registerMiPush:self type:0 connect:YES]; center.delegate = self; } else { // 注册推送,如果iOS10以下 [MiPushSDK registerMiPush:self type:0 connect:YES]; }}
#pragma mark 注册push服务.- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { // 注册APNS成功, 注册deviceToken [MiPushSDK bindDeviceToken:deviceToken];}- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err { // 注册APNS失败. // 自行处理.}#pragma mark Local And Push Notification//自此而下2个方法是iOS新加入的回调方法,这两个是UNUserNotificationCenterDelegate协议中的两个方法。- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { //应用在前台收到通知 NSLog(@"========%@", notification); NSDictionary * userInfo = notification.request.content.userInfo; if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { [MiPushSDK handleReceiveRemoteNotification:userInfo]; } completionHandler(UNNotificationPresentationOptionAlert);}- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { //点击通知进入应用 NSLog(@"response:%@", response); NSDictionary * userInfo = response.notification.request.content.userInfo; if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { [MiPushSDK handleReceiveRemoteNotification:userInfo]; } completionHandler();}//iOS10之前的方法,这保留- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [MiPushSDK handleReceiveRemoteNotification:userInfo]; completionHandler(UIBackgroundFetchResultNewData);}- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { // 当同时启动APNs与内部长连接时, 把两处收到的消息合并. 通过miPushReceiveNotification返回 [MiPushSDK handleReceiveRemoteNotification:userInfo];}#pragma mark MiPushSDKDelegate- (void)miPushRequestSuccWithSelector:(NSString *)selector data:(NSDictionary *)data { NSLog(@"==== > %@", data);}- (void)miPushRequestErrWithSelector:(NSString *)selector error:(int)error data:(NSDictionary *)data { NSLog(@"==== > %@", data);}- (void)miPushReceiveNotification:(NSDictionary*)data { // 1.当启动长连接时, 收到消息会回调此处 // 2.[MiPushSDK handleReceiveRemoteNotification] // 当使用此方法后会把APNs消息导入到此}
虽然这个可以解决收发push的问题,但是还是希望MiPush可以更新。
Pass_4
UIApplication对象中openUrl被废弃
在iOS 10全新的推出了[UIApplication sharedApplication] openURL:nil options:nil completionHandler:^(BOOL success);有一个成功的回调block 可以进行监视。目前来说,以前的openUrl方法还能用。最好来说是要根据版本做适配
Pass_5
iOS版本检查
下边的方法不可以再继续使用了
[[[UIDevice currentDevice] systemVersion] substringToIndex:1]
因为substringToIndex:1 in SDK ‘iOS 10.0’(Xcode 8) means SDK ‘iOS 1.0’
可以换成
[UIDevice currentDevice].systemVersion.floatValue
0 0
- iOS_Pass iOS10适配:权限访问、MiPush小米推送(更新中)
- iOS_Pass iOS10获取相册权限崩溃crash解决方法
- iOS_Pass iOS10获取相册权限崩溃crash解决方法
- iOS10中访问权限的设置
- iOS10 权限访问崩溃
- ios10 相册权限访问
- iOS10 权限访问Crash问题
- iOS10访问权限问题Crash解决方法
- 米推(MiPush)简述
- iOS10 推送
- 适配iOS10的权限设置
- 苹果系统更新权限配置:ios10 配置权限
- iOS10推送通知进阶(Notification Extension)
- IOS10 Notification推送通知(一)
- IOS10 Notification推送通知(二)
- IOS10 Notification远程推送通知(三)
- iOS10 添加本地推送(Local Notification)
- [绍棠] iOS中 iOS10 权限崩溃问题
- 【技术支持】各种数据库DB管理工具
- 基础篇:操作系统、计算机网络、设计模式
- 用VMware Workstation 11的LAN区段功能构造内网环境
- 职场宝典
- Android 6.0指纹识别App开发demo
- iOS_Pass iOS10适配:权限访问、MiPush小米推送(更新中)
- WEB前端 | H5基础——(1)H5新增标签
- python面向对象实现K均值聚类
- Wdatepicker日期控件的使用指南
- updates is listed more than once in the configuration 的解决
- webpack入坑之旅
- 解决Android Studio加载第三方jar包,出现包重复加载的问题:
- Java并发专题 带返回结果的批量任务执行 CompletionService ExecutorService.invokeAll
- 51nod 1136 欧拉函数(欧拉函数)