ios8以前 註冊通知的方法是ios
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge];
ios8 註冊這樣寫app
UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil];
[application registerUserNotificationSettings:setting];
有關CLLocationManageroop
locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; [locationManager startUpdatingLocation];
ios8以後添加了 [locationManager requestAlwaysAuthorization];post
其餘的內容沒什麼變化 info.plist中 添加兩個字段NSLocationWhenInUseUsageDescription和NSLocationAlwaysUsageDescription編碼
定位之後的回調方法以下atom
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locationsspa
在這個方法裏能夠拿到經緯度 控制定位結束 能夠地理反編碼 拿到當前的位置信息rest
CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks, NSError *error) { for (CLPlacemark *place in placemarks) { NSLog(@"name,%@",place.name); // 位置 [manager stopUpdatingLocation]; } }]; //有關 這個CLPlacemark 能夠點進去查看 /*包括街道信息也能夠拿到 @property (nonatomic, readonly, copy) NSDictionary *addressDictionary; // address dictionary properties @property (nonatomic, readonly, copy) NSString *name; // eg. Apple Inc. @property (nonatomic, readonly, copy) NSString *thoroughfare; // street address, eg. 1 Infinite Loop @property (nonatomic, readonly, copy) NSString *subThoroughfare; // eg. 1 @property (nonatomic, readonly, copy) NSString *locality; // city, eg. Cupertino @property (nonatomic, readonly, copy) NSString *subLocality; // neighborhood, common name, eg. Mission District @property (nonatomic, readonly, copy) NSString *administrativeArea; // state, eg. CA @property (nonatomic, readonly, copy) NSString *subAdministrativeArea; // county, eg. Santa Clara @property (nonatomic, readonly, copy) NSString *postalCode; // zip code, eg. 95014 @property (nonatomic, readonly, copy) NSString *ISOcountryCode; // eg. US @property (nonatomic, readonly, copy) NSString *country; // eg. United States @property (nonatomic, readonly, copy) NSString *inlandWater; // eg. Lake Tahoe @property (nonatomic, readonly, copy) NSString *ocean; // eg. Pacific Ocean @property (nonatomic, readonly, copy) NSArray *areasOfInterest; // eg. Golden Gate Park */