2014-07-16 33 views
0

根據已解決的iBeacon Bluetooth didEnterRegion and didExitRegion methods are never fired中的問題,這是一個進一步的問題。didEnterRegion()/ didExitRegion()永遠不會在應用程序在後臺或設備鎖定時被觸發

詳細地,didEnterRegion和didExitRegion的方法,而在背景或設備信標應用程序鎖定被從未燒成。另外,這兩種方法可以在正常情況下觸發,而前臺的信標應用程序。

基於蘋果演示「Airlocated(示例代碼,由蘋果公司提供)」中的波紋管連接我的應用程序是https://developer.apple.com/library/ios/samplecode/AirLocate/Introduction/Intro.html#//apple_ref/doc/uid/DTS40013430-Intro-DontLinkElementID_2。我幾乎不修改任何代碼,只是加入一些代碼波紋管:

文件

「APLAppDelegate.m」

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region 
{ 
    NSLog(@"Entered region: %@", region); 

    [self sendLocalNotificationForBeaconRegion:(CLBeaconRegion *)region]; 
} 


- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region 
{ 
    NSLog(@"Exited region: %@", region); 
} 

文件APLMonitoringViewcontroller.m

- (void)updateMonitoredRegion 
{ 
... 

      [self.locationManager startMonitoringForRegion:region]; 
      [self.locationManager startRangeingForRegion:region]; 
... 
} 

補位。我曾嘗試波紋管方法:

  • 集 「位置更新」 後臺模式,是
  • 指定notifyOnExit和notifyOnEntry爲真
  • 重啓的iPhone4s與iOS 7.1.2

誰能給我有一些建議呢?

回答

2

你等待背景檢測有多長時間?在某些情況下,這可能需要15分鐘。 See here for details.

如該文章所述,您不需要將位置更新背景模式設置爲YES,也不需要將notifyOnExit和notifyOnEntry指定爲true。

+0

由於網絡問題,對於遲到的回覆感到抱歉。感謝您提醒進入和退出信標區域,尤其是在應用程序處於後臺時不是各自提醒。我在你的文章中迷失了相對的點。 –

+0

來優化信標區域更改通知,似乎沒有有效的解決方案來解決延遲問題,而iBeacon應用程序在後臺而不是前臺。是嗎? –

相關問題