Ich habe ein Problem mit der Region Überwachung, während die App im Hintergrund ist. Region wird betreten und verlassen wird aufgerufen, wenn die App im Vordergrund ist, aber nicht im Hintergrund (manchmal feuern sie aber sehr selten).Region Überwachung Beacon Regionen im Hintergrund funktioniert nicht
Wie funktioniert die Beacon-Region-Überwachung für iOS 8.1.1? Sollte die Region das Feuer betreten/verlassen, wenn sie sich im Hintergrund in Beacon Nähe befindet?
Was muss ich tun, um sicherzustellen, dass es funktioniert?
Do Background Modes
: Location Updates
oder Uses Bluetooth LE accessories
müssen eingeschaltet sein, damit die Hintergrundbakenüberwachung funktioniert? GeoFencing hat für mich funktioniert, ohne dass diese eingeschaltet waren.
Was habe ich schon gemacht:
setzen diese für jede Region:
beaconRegion.notifyOnExit=YES; beaconRegion.notifyOnEntry=YES; beaconRegion.notifyEntryStateOnDisplay = YES;
- dafür gesorgt, dass alles in den Einstellungen in Ordnung (App aktualisieren etc.)
EDIT:
Ich habe ein neues Projekt erstellt und es funktioniert immer noch nicht. Hier ist der Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.pausesLocationUpdatesAutomatically = NO;
_locationManager.desiredAccuracy = 25;
_locationManager.delegate = self;
[_locationManager requestAlwaysAuthorization];
[_locationManager startUpdatingLocation];
CLBeaconRegion* reg =[self prepareBeacon:@"here i put my UUID" :446 :2196];
[_locationManager startMonitoringForRegion:reg];
[_locationManager startRangingBeaconsInRegion:reg];
return YES;
}
-(CLBeaconRegion*)prepareBeacon:(NSString*)uuid :(int)maj :(int)min
{
NSString* identifier = [NSString stringWithFormat:@"%@,%d,%d", uuid, maj, min];
CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:uuid] major:maj minor:min identifier:identifier];
beaconRegion.notifyOnExit=YES;
beaconRegion.notifyOnEntry=YES;
beaconRegion.notifyEntryStateOnDisplay = YES;
return beaconRegion;
}
-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{
}
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
}
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
}
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
{
}
einige zusätzliche Informationen:
- Außer ein frisches iOS8 Projekt Erstellen und Hinzufügen von Code, den ich habe
NSLocationAlwaysUsageDescription
zu * .plist-Datei hinzugefügt. - Ich setze Haltepunkte in
didEnterRegion
unddidExitRegion
. Es funktioniert im Vordergrund, funktioniert nicht, während im Hintergrund (iPhone in Home-Bildschirm oder gesperrt) - Testing auf 4S, iOS 8.1.1
Keine Notwendigkeit, Hintergrund-Modi für iBeacons zu setzen –