2016-03-23 5 views
0

Das Folgende ist mein Code, der das Beacon erkennt, aber im Hintergrund sendet es keine Benachrichtigung. Kann jemand verfolgen, was genau das Problem mit dem Code istHintergrund Benachrichtigung von Beacon iOS mit ESTBeaconManager

@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];} 

ich diese Nachricht erhalten, wenn ich den Stack-Trace-Gerät finden Sie unter:

„-iPhone ESTBeacon [1366]: monitoringDidFailForRegion Unzureichende Location Services Genehmigung. Die Überwachung wird angehalten, bis die entsprechende Genehmigung erteilt wird. "

Obwohl ich requestWhenInUseAuthorization in info plist

+0

verwenden Sie IBeacon oder eddystore konfiguriert? –

Antwort

0

hinzugefügt haben, ich vermute, Ihre App wurde Berechtigungen Standort nicht gewährt. Um dies zu überprüfen, gehen Sie zu Einstellungen -> und prüfen Sie, ob Ihre App die Standortberechtigung "Immer" hat. Wenn dies der Fall ist, sollte es wie im Screenshot unten aussehen.

Wenn Sie keinen Standortzugriff gewährt haben, überprüfen Sie Ihren Code, der es anfordert. Neben einem Eintrag in Ihrem plist, müssen Sie etwas wie folgt aus:

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

enter image description here

Verwandte Themen