Ios 当应用程序在'上进入后台时阅读钥匙链;迪登特地区';伊贝肯

Ios 当应用程序在'上进入后台时阅读钥匙链;迪登特地区';伊贝肯,ios,objective-c,iphone,ibeacon,keychainitemwrapper,Ios,Objective C,Iphone,Ibeacon,Keychainitemwrapper,我正在开发一个iBeacon支持的iOS应用程序,当该应用程序进入受监控iBeacon所在的区域时,需要从终止状态返回后台,然后发送HTTP请求。除无法读取保存在钥匙链中的某些凭证信息外,所有工作正常。 我不确定这是否与Keychain或iBeacon有关,或者两者都有。但我的代码就是这样的 当我保存凭据时(我使用应用程序密钥链包装代码) 现在,iBeacon部分 - (void)locationManager:(CLLocationManager *)manager didDetermin

我正在开发一个iBeacon支持的iOS应用程序,当该应用程序进入受监控iBeacon所在的区域时,需要从终止状态返回后台,然后发送HTTP请求。除无法读取保存在钥匙链中的某些凭证信息外,所有工作正常。 我不确定这是否与Keychain或iBeacon有关,或者两者都有。但我的代码就是这样的

当我保存凭据时(我使用应用程序密钥链包装代码)

现在,iBeacon部分

- (void)locationManager:(CLLocationManager *)manager
  didDetermineState:(CLRegionState)state
          forRegion:(CLBeaconRegion *)region
{

if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
{
    // don't send any notifications
    return;
}

if (state == CLRegionStateInside)
{
    NSLog(@"Inside beacon region");

    KeychainItemWrapper* keyChain = [[KeychainItemWrapper alloc] initWithIdentifier:keyChainIdentifier accessGroup:nil];

    NSString *username =[keyChain objectForKey:(__bridge id)kSecAttrAccount];
    NSString *password =[keyChain objectForKey:(__bridge id)kSecValueData];

    [self.locationManager startRangingBeaconsInRegion:region];

    if (username.length > 0 && password.length > 0 ) {
        [self sendRequest:userName passCode:password];
    }else {
        // This is where it ends up when the app is TERMINATED and entering to the region !!!
        [self displayError];
        NSLog(@"I CAN SEE THIS !!!");
    }

}
 }
我关闭应用程序,锁定屏幕,然后在握住设备的同时进入iBeacon区域,然后我可以看到所有事情都按照逻辑进行,但只能看到错误消息。
任何帮助都将不胜感激

有人面临同样的问题吗?我在这里做了一些愚蠢的事情,难道在iBeacon事件中应用程序唤醒30秒时,连钥匙链都不可能访问吗?还向Apple iOS开发者论坛添加了一个问题,以及如果将访问类型设置为“ksecAttracibleAllways”,会发生什么情况。我知道苹果建议不要这样做,但这可能有助于确定问题的根本原因。
- (void)locationManager:(CLLocationManager *)manager
  didDetermineState:(CLRegionState)state
          forRegion:(CLBeaconRegion *)region
{

if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
{
    // don't send any notifications
    return;
}

if (state == CLRegionStateInside)
{
    NSLog(@"Inside beacon region");

    KeychainItemWrapper* keyChain = [[KeychainItemWrapper alloc] initWithIdentifier:keyChainIdentifier accessGroup:nil];

    NSString *username =[keyChain objectForKey:(__bridge id)kSecAttrAccount];
    NSString *password =[keyChain objectForKey:(__bridge id)kSecValueData];

    [self.locationManager startRangingBeaconsInRegion:region];

    if (username.length > 0 && password.length > 0 ) {
        [self sendRequest:userName passCode:password];
    }else {
        // This is where it ends up when the app is TERMINATED and entering to the region !!!
        [self displayError];
        NSLog(@"I CAN SEE THIS !!!");
    }

}
 }