APP 适配 iOS8,位置、通知等特性
2015-06-04 13:08
357 查看
跳转到系统 App 设置
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
位置访问添加 开始-结束 之间代码请求询问
接受推送通知添加如下
在 APPDelegate 中对应位置添加
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
位置访问添加 开始-结束 之间代码请求询问
self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; //开始 if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) { [self.locationManager requestWhenInUseAuthorization]; } //结束 [self.locationManager startUpdatingLocation];------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
接受推送通知添加如下
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) { UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; <span style="white-space:pre"> </span>[[UIApplication sharedApplication] registerForRemoteNotifications]; //<span style="color:#ff0000;">或者使用"在 APPDelegate 中对应位置添加" 2选1</span> } else { //原来注册通知的代码 [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)]; }
在 APPDelegate 中对应位置添加
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { if (notificationSettings.types != UIUserNotificationTypeNone) { [application registerForRemoteNotifications]; } }
相关文章推荐
- iOS使用CoreImage处理图像40中可用的滤镜名称
- WINDOWS.H already included. MFC apps must not #include <windows.h>
- 菜鸟学Android(二十):Servlet的调用过程
- Android VLC播放器二次开发2——CPU类型检查+界面初始化
- iOS开发的一些奇巧淫技
- Android(java)学习笔记99:android的短信发送器研究
- 【Android动画】之Tween动画 (渐变、缩放、位移、旋转)
- Android LayoutInflater详解
- android viewpager教您打造炫酷的(从左到右,从上到下)引导页 随便玩!
- IE ActiveObject
- iOS 使用Quartz 2D画虚线
- Android 微信支付body参数不支持中文的问题
- 两种Context的区别,Activity 和Application
- Mybatis学习笔记-sqlMapper
- android_基本控件学习当中出现的问题总结及工作问题思考
- 【Android开发】消息处理类(Handler)与消息类(Message)介绍
- Cocos国外大牛分享次世代画质3D案例
- iOS 代码实现自动布局(Auto Layout)第三方库
- android 自定义ImageView实现图片缩放边界回弹和缩小回弹
- Android 读取手机某个文件夹目录及子文件夹中所有的txt文件