ios8中修改的 推送和地圖

來源:互聯網
上載者:User

標籤:

ios8之前 註冊通知的方法是

       [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge];

ios8 註冊這樣寫

    UIUserNotificationSettings *setting = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil];    [application registerUserNotificationSettings:setting];

 

有關CLLocationManager

    locationManager = [[CLLocationManager alloc] init];    locationManager.delegate = self;    [locationManager startUpdatingLocation];

ios8之後添加了    [locationManager requestAlwaysAuthorization];

其他的內容沒什麼變化 info.plist中 添加兩個欄位NSLocationWhenInUseUsageDescription和NSLocationAlwaysUsageDescription

 定位以後的回調方法如下

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations

在這個方法裡可以拿到經緯度 控制定位結束 可以地理反編碼 拿到當前的位置資訊

 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*/

 

ios8中修改的 推送和地圖

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.