Ranging Beacons funktionieren nur, wenn die App ausgeführt wird?

Ich habe Schwierigkeiten, dies zum Laufen zu bringen, wenn die App nicht läuft. ich habelocationManager:didRangeBeacons:inRegion: implementiert und es wird aufgerufen, wenn die App im Vordergrund oder Hintergrund ausgeführt wird, es scheint jedoch nichts zu tun, wenn ich die App beende und den Bildschirm sperre. Das Symbol für Ortungsdienste verschwindet, und ich weiß nie, dass ich in eine Leuchtfeuer-Reichweite eingetreten bin. Sollte die LocalNotification noch funktionieren?

Ich habe Standortaktualisierungen und verwende Bluetooth LE-Zubehör, das in den Hintergrundmodi (XCode 5) ausgewählt wurde. Ich habe nicht gedacht, dass ich sie benötige.

Jede Hilfe sehr geschätzt.

-(void)watchForEvents { // this is called from application:didFinishLaunchingWithOptions
    id class = NSClassFromString(@"CLBeaconRegion");
    if (!class) {
        return;
    }

    CLBeaconRegion * rflBeacon = [[CLBeaconRegion alloc] initWithProximityUUID:kBeaconUUID identifier:kBeaconString];
    rflBeacon.notifyOnEntry = YES;
    rflBeacon.notifyOnExit = NO;
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    [self.locationManager startRangingBeaconsInRegion:rflBeacon];
    [self.locationManager startMonitoringForRegion:rflBeacon];
}

-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
    if (beacons.count == 0 || eventRanged) { // breakpoint set here for testing
        return;
    }

    eventRanged = YES;
    if (backgroundMode) { // this is set in the EnterBackground/Foreground delegate calls
        UILocalNotification *notification = [[UILocalNotification alloc] init];
        notification.alertBody = [NSString stringWithFormat:@"Welcome to the %@ event.",region.identifier];
        notification.soundName = UILocalNotificationDefaultSoundName;
        [[UIApplication sharedApplication] presentLocalNotificationNow:notification];
    }

    // normal processing here...
}

Antworten auf die Frage(6)

Ihre Antwort auf die Frage