第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

背景位置服務不適用于IOS 7

背景位置服務不適用于IOS 7

猛跑小豬 2019-07-20 09:47:14
背景位置服務不適用于IOS 7我最近升級了我的iOS設備以使用iOS 7。我們正在開發(fā)的一個應用程序使用后臺定位服務來跟蹤設備位置,我們的所有測試人員都報告說,該應用程序似乎不再跟蹤iOS 7下的背景信息。我們已經(jīng)證實,在設備上的設置中啟用了該應用程序的回退,而之前的構建在iOS 6下運行得非常完美。即使該設備被循環(huán)使用,該應用程序在位置更新后也會重新啟動。在iOS 7下,是否還需要做一些其他的工作呢?
查看完整描述

3 回答

?
汪汪一只貓

TA貢獻1898條經(jīng)驗 獲得超8個贊

方法和解釋:-

  1. 我每1分鐘重新啟動一次位置管理器。DIDUpdateLocations

  2. 我允許位置管理器從設備中獲取10秒的位置,然后關閉它(以節(jié)省電池)。

以下部分法典:-

-(void)locationManager:(CLLocationManager?*)manager?didUpdateLocations:(NSArray?*)locations{for(int?i=0;i<locations.count;i++){
????CLLocation?*?newLocation?=?[locations?objectAtIndex:i];
????CLLocationCoordinate2D?theLocation?=?newLocation.coordinate;
????CLLocationAccuracy?theAccuracy?=?newLocation.horizontalAccuracy;
????NSTimeInterval?locationAge?=?-[newLocation.timestamp?timeIntervalSinceNow];

????if?(locationAge?>?30.0)
????????continue;

????//Select?only?valid?location?and?also?location?with?good?accuracy
????if(newLocation!=nil&&theAccuracy>0
???????&&theAccuracy<2000
???????&&(!(theLocation.latitude==0.0&&theLocation.longitude==0.0))){
????????self.myLastLocation?=?theLocation;
????????self.myLastLocationAccuracy=?theAccuracy;
????????NSMutableDictionary?*?dict?=?[[NSMutableDictionary?alloc]init];
????????[dict?setObject:[NSNumber?numberWithFloat:theLocation.latitude]?forKey:@"latitude"];
????????[dict?setObject:[NSNumber?numberWithFloat:theLocation.longitude]?forKey:@"longitude"];
????????[dict?setObject:[NSNumber?numberWithFloat:theAccuracy]?forKey:@"theAccuracy"];
????????//Add?the?vallid?location?with?good?accuracy?into?an?array
????????//Every?1?minute,?I?will?select?the?best?location?based?on?accuracy?and?send?to?server
????????[self.shareModel.myLocationArray?addObject:dict];
????}}//If?the?timer?still?valid,?return?it?(Will?not?run?the?code?below)if?(self.shareModel.timer)
????return;self.shareModel.bgTask?=?[BackgroundTaskManager?sharedBackgroundTaskManager];[self.shareModel.bgTask?beginNewBackgroundTask];//Restart?the?locationMaanger?after?1?minuteself.shareModel.timer?=?[NSTimer?scheduledTimerWithTimeInterval:60?target:self
???????????????????????????????????????????????????????selector:@selector(restartLocationUpdates)
???????????????????????????????????????????????????????userInfo:nil
????????????????????????????????????????????????????????repeats:NO];//Will?only?stop?the?locationManager?after?10?seconds,?so?that?we?can?get?some?accurate?locations//The?location?manager?will?only?operate?for?10?seconds?to?save?batteryNSTimer?*?delay10Seconds;delay10Seconds?=?[NSTimer?scheduledTimerWithTimeInterval:10?target:self
????????????????????????????????????????????????selector:@selector(stopLocationDelayBy10Seconds)
????????????????????????????????????????????????userInfo:nil
?????????????????????????????????????????????????repeats:NO];
?}

我收到了一些請求,要求在一定時間間隔內(nèi)向服務器發(fā)送位置時添加示例代碼。我添加了示例代碼,并結合了背景任務管理器的修復來解決后臺運行較長時間的故障。


查看完整回答
反對 回復 2019-07-20
?
慕神8447489

TA貢獻1780條經(jīng)驗 獲得超1個贊

我認為他們做了一個優(yōu)化(可能使用運動傳感器),以檢測手機的“相對”靜止定位,他們停止位置更新。這只是猜測,但我目前的測試顯示:

  1. 開始位置更新;(測試精度為10米和100米,每次3次)
  2. 關閉設備屏幕,將應用程序放到后臺;
  3. 將設備靜止不動(例如在桌子上)30分鐘。

我記錄的數(shù)據(jù)顯示,地學更新在大約15米和30米之后停止。這樣,您所做的所有其他后臺處理也將終止。

我的設備是iPhone 5和iOS 7。

我95%肯定,iOS 6/6.1的情況并非如此。在那里獲得100米精度的地理更新,可以讓你在后臺連續(xù)運行。

如果每8分鐘重新啟動一次位置管理器,它應該會連續(xù)運行。

我還沒有在最新的測試,但這是我如何重新啟動它時,我寫了這篇文章。我希望這是有幫助的。

- (void)tryRestartLocationManager{
    NSTimeInterval now = [[NSDate date] timeIntervalSince1970];

    int seconds = round(floor(now - locationManagerStartTimestamp));

    if ( seconds > (60 * 8) ) {
        [locationManager stopUpdatingLocation];
        [locationManager startUpdatingLocation];
        locationManagerStartTimestamp = now;
    }}

查看完整回答
反對 回復 2019-07-20
  • 3 回答
  • 0 關注
  • 491 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號