Os beacons somente funcionam quando o aplicativo está em execução?
Estou tendo dificuldades para fazer isso funcionar quando o aplicativo não está em execução. eu tenholocationManager:didRangeBeacons:inRegion:
implementado e é chamado quando o aplicativo está sendo executado em primeiro plano ou plano de fundo, no entanto, não parece fazer nada quando eu sair do aplicativo e bloquear a tela. O ícone dos serviços de localização desaparece e nunca sei que entrei em um intervalo de sinalização. O LocalNotification ainda deve funcionar?
Eu tenho atualizações de localização e usa acessórios Bluetooth LE selecionados em modos de fundo (XCode 5) Eu não acho que eu precisava deles.
Qualquer ajuda muito apreciada.
-(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...
}