标签:ios8新特性 基于地理位置的消息通知 uilocalnotification 基站 ios8
CLLocationManager *locMan = [[CLLocationManager alloc] init]; locMan.delegate = self; // request authorization to track the user’s location [locMan requestWhenInUseAuthorization];同时还要进行配置plist文件
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { // check status to see if we’re authorized BOOL canUseLocationNotifications = (status == kCLAuthorizationStatusAuthorizedWhenInUse); if (canUseLocationNotifications) { [self startShowingLocationNotifications]; } }回调方法里注册通知
- (void)startShowingNotifications { UILocalNotification *locNotification = [[UILocalNotification alloc] init]; locNotification.alertBody = @“You have arrived!”; locNotification.regionTriggersOnce = YES; locNotification.region = [[CLCircularRegion alloc] initWithCenter:LOC_COORDINATE radius:LOC_RADIUS identifier:LOC_IDENTIFIER]; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; } //- (instancetype)initWithCenter:(CLLocationCoordinate2D)center //区域的中心 经纬度 // radius:(CLLocationDistance)radius //区域半径 范围 // identifier:(NSString *)identifier; //通知的唯一标示 描述
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { NSLog(@"%s",__func__); } - (void)application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification { CLRegion *region = notification.region; if (region) { [self tellFriendsUserArrivedAtRegion:region]; } }
iOS8新特性之基于地理位置的消息通知UILocalNotification,布布扣,bubuko.com
iOS8新特性之基于地理位置的消息通知UILocalNotification
标签:ios8新特性 基于地理位置的消息通知 uilocalnotification 基站 ios8
原文地址:http://blog.csdn.net/yujianxiang666/article/details/36007913