2016-03-23 6 views
0

以下はビーコンを検出している私のコードですが、バックグラウンドでは通知を送信しません。私は、デバイスのスタックトレースを見ると 誰もが正確にコードESTBeaconManagerを使用したBeacon iOSからのバックグラウンド通知

@property (nonatomic) ESTBeaconManager *beaconManager; 
@property (strong, nonatomic) CLBeaconRegion *beacRegion; 
@property (strong, nonatomic) NSArray *estimoteBeacons; 
- (void)viewDidLoad { 
self.beaconManager = [ESTBeaconManager new]; 
self.beaconManager.delegate = self; 
self.beaconManager.returnAllRangedBeaconsAtOnce = YES; 


self.beacRegion = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"xxxxxx-xxxx-xxxx-xxxx-..."] major:000 minor:0000 identifier:[NSString stringWithFormat:@"%@", @"HEY GUYS!"]]; 
    [self.beaconManager startRangingBeaconsInRegion:self.beacRegion]; 
[self.beaconManager startMonitoringForRegion:self.beacRegion]; 

} 

- (void)beaconManager:(id)manager didEnterRegion:(CLBeaconRegion *)region 
{ 
NSLog(@"didEnterRegion"); 
UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
localNotification.alertBody = @"You have entered the region you are monitoring"; 
localNotification.soundName = UILocalNotificationDefaultSoundName; 
[[UIApplication sharedApplication]presentLocalNotificationNow:localNotification];} 

    - (void)beaconManager:(id)manager didEnterRegion:(CLBeaconRegion *)region 
{ 
NSLog(@"didEnterRegion"); 
UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
localNotification.alertBody = @"You have left the region you are monitoring"; 
localNotification.soundName = UILocalNotificationDefaultSoundName; 
[[UIApplication sharedApplication]presentLocalNotificationNow:localNotification];} 

に問題が何であるかを追跡することができます私はこのメッセージが表示されます。

「-iPhone ESTBeacon [1366]:monitoringDidFailForRegion不十分な場所のサービスの承認。適切な許可が付与されるまで監視は中断されます。私はあなたのアプリケーションは、場所の権限を付与されていない疑いがある情報のplist

+0

:あなたのplistのエントリに加えて、あなたはこのようなものが必要? –

答えて

0

でrequestWhenInUseAuthorizationを追加したものの

。確認するには、[設定] - >にアクセスして、アプリに「常に」所在地権限があるかどうかを確認します。表示されている場合は、以下のスクリーンショットのようになります。

ロケーションアクセスが許可されていない場合は、リクエストするコードを確認してください。あなたが設定さibeaconまたはeddystoreを使用している

if([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { 
    [locationManager requestAlwaysAuthorization]; 
} 

enter image description here

関連する問題