1
我想在後臺搜索RSSI。我正在嘗試通過調用相同函數中的函數來完成此操作。有沒有辦法讓這個循環生活在後臺模式。正如我所看到的那樣,它應該生活在背景中,但是我會在som milliesecounds之後死去。如何使它保持搜索?在後臺模式下循環
- (void)applicationWillResignActive:(UIApplication *)application
{
if([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)])
{
NSLog(@"Multitasking Supported");
}
else
{
NSLog(@"Multitasking Not Supported");
}
NSLog(@"Start background task");
mBeaconDeviceList = [[NSMutableArray alloc] init];
mBeaconConfigManager = [[JLEBeaconConfigManager alloc] init];
mBeaconConfigManager.delegate = self;
[mBeaconConfigManager startJaaleeBeaconsDiscovery];
}
#pragma mark - JLEBeaconConfigManager delegate
-(void)beaconConfigManager:(JLEBeaconConfigManager *)manager didDiscoverBeacon:(JLEBeaconDevice *)beacon RSSI:(NSNumber *)RSSI AdvData:(NSDictionary *)AdvData
{
NSLog(@"Find RSSI");
if ([RSSI intValue] > 0 || [RSSI intValue] < -40) {
return;
}
if ([mBeaconDeviceList containsObject:beacon]) {
[mBeaconDeviceList removeObject:beacon];
}
[mBeaconDeviceList addObject:beacon];
NSLog(@"FOUND: %@", RSSI);
NSLog(@"Start again");
mBeaconDeviceList = [[NSMutableArray alloc] init];
mBeaconConfigManager.delegate = self;
[mBeaconConfigManager startJaaleeBeaconsDiscovery];
}
我不認爲時間現在是問題。問題在於'beaconConfigManager'方法在'applicationWillResignActive'處被調用,但是當它進入'applicationDidEnterBackground'時,方法'beaconConfigManager'停止發送響應。 – TheZozoOwner