XcodeとローカルのMacでインストールしたテストでうまく動作するiOS 9.2アプリがあります。このアプリケーションをMDMサーバーからインストールすると、データの最初のアクセス時にクラッシュします。 「10.00秒後にシーン更新に失敗しました」というエラーが表示されて終了します。コンソール出力をチェックするからMDMからインストールした後、エンタープライズアプリケーションのクラッシュが発生する
私は、それが後に(requireLogin方法で成功プロセスの後にハングアップしているように見える[自己checkIntSession:self.sessionDetail]。
私たちは、NovellのMDMないアップルのバージョンを使用しています私はインストールして問題なく実行している他のアプリケーションを作成しました。
クリーンビルドとインストールを試しましたが、それは助けになりませんでした。次のどこに行かなければならないのか分かりません。どんな助けもありがたいです。
#import "Security.h"
#import "XMLTypeItem.h"
#import "ParseTypeXML.h"
#import "XMLPostSecurity.h"
#import "XMLSessionItem.h"
#import "FileSaving.h"
#import <LocalAuthentication/LocalAuthentication.h>
@implementation Security
- (NSString *)retrieveESN {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *directoryPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [directoryPaths objectAtIndex:0];
NSString *fullPath = [documentsDirectoryPath stringByAppendingString:@"/session.txt"];
if ([fileManager fileExistsAtPath:fullPath]==YES) {
_finished = false;
[self readSession];
NSString *result = [self checkSession:_sessionDetail];
if ([result isEqualToString:@"Error"]) {
NSString *userESN = [self newFile];
if (self.getUserESN){
self.getUserESN(userESN);
}
return userESN;
} else {
return result;
}
} else {
_finished = false;
NSString *userESN = [self newFile];
return userESN;
}
}
- (NSString *)newFile {
[self requireLogin];
if (self.findUserESN) {
self.findUserESN(_passESN);
}
return _passESN;
}
- (void)requestSession {
NSString *idfv = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
NSString *url = @"https://company.com/loginfile";
NSMutableString *postText = [[NSMutableString alloc] init];
[postText appendString:idfv];
NSString *postBody = [NSString stringWithString:postText];
XMLPostSecurity *postAction = [[XMLPostSecurity alloc] init];
_sessionDetail = [postAction sendPostRequestToUrl:url withBody:postBody];
FileSaving *saver = [[FileSaving alloc] init];
[saver saveSession:self.sessionDetail];
}
-(NSString *)readSession {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *directoryPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [directoryPaths objectAtIndex:0];
NSString *fullPath = [documentsDirectoryPath stringByAppendingString:@"/session.txt"];
if (self.fileExistsNow) {
self.fileExistsNow([fileManager fileExistsAtPath:fullPath]);
}
NSFileManager *fileManagerTwo;
NSData *dataBuffer;
fileManagerTwo = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingString:@"/session.txt"];
dataBuffer = [fileManagerTwo contentsAtPath:filePath];
_sessionDetail = [[NSString alloc] initWithData:dataBuffer encoding:(NSASCIIStringEncoding)];
return _sessionDetail;
}
-(void)readIntSession {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *directoryPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [directoryPaths objectAtIndex:0];
NSString *fullPath = [documentsDirectoryPath stringByAppendingString:@"/session.txt"];
if (self.fileExistsNow) {
self.fileExistsNow([fileManager fileExistsAtPath:fullPath]);
}
NSFileManager *fileManagerTwo;
NSData *dataBuffer;
fileManagerTwo = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingString:@"/session.txt"];
dataBuffer = [fileManagerTwo contentsAtPath:filePath];
_sessionDetail = [[NSString alloc] initWithData:dataBuffer encoding:(NSASCIIStringEncoding)];
}
-(NSString *)checkSession:(NSString *)sessionFound {
NSDictionary *cookieProperties = [NSDictionary dictionaryWithObjectsAndKeys:
@"ollie/", NSHTTPCookieDomain,
@"\\", NSHTTPCookiePath,
@"Cookie", NSHTTPCookieName,
sessionFound, NSHTTPCookieValue,
nil];
NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
NSArray *cookieArray = [NSArray arrayWithObject:cookie];
NSDictionary *headers = [NSHTTPCookie requestHeaderFieldsWithCookies:cookieArray];
NSMutableString *url = [[NSMutableString alloc] initWithString:@"https://company.com/file.php"];
NSURL *urlNew = [NSURL URLWithString:url];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlNew];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
return;
}
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
if (statusCode != 200) {
if (statusCode == 401) {
// Insert process for thumbprint and session cookie pull
NSFileManager *fileManagerThree = [NSFileManager defaultManager];
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *sessionPath = [documentsPath stringByAppendingPathComponent:@"session.txt"];
NSError *error;
BOOL success = [fileManagerThree removeItemAtPath:sessionPath error:&error];
if (success) {
} else {
}
} else {
return;
}
}
}
self.parseData = data;
}];
[task resume];
if (self.parseDataAvailable) {
self.parseDataAvailable(self.parseData);
}
ParseTypeXML *myParser = [[ParseTypeXML alloc] initWithData:self.parseData];
if ([myParser.esn count] == 0) {
return @"Error";
} else {
return myParser.esn[0];
}
}
-(void)checkIntSession:(NSString *)sessionFound {
NSDictionary *cookieProperties = [NSDictionary dictionaryWithObjectsAndKeys:
@"ollie/", NSHTTPCookieDomain,
@"\\", NSHTTPCookiePath,
@"Cookie", NSHTTPCookieName,
sessionFound, NSHTTPCookieValue,
nil];
NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
NSArray *cookieArray = [NSArray arrayWithObject:cookie];
NSDictionary *headers = [NSHTTPCookie requestHeaderFieldsWithCookies:cookieArray];
NSMutableString *url = [[NSMutableString alloc] initWithString:@"https://company.com/file.php"];
NSURL *urlNew = [NSURL URLWithString:url];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlNew];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
return;
}
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
if (statusCode != 200) {
if (statusCode == 401) {
// Insert process for thumbprint and session cookie pull
NSFileManager *fileManagerThree = [NSFileManager defaultManager];
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *sessionPath = [documentsPath stringByAppendingPathComponent:@"session.txt"];
NSError *error;
BOOL success = [fileManagerThree removeItemAtPath:sessionPath error:&error];
if (success) {
} else {
}
} else {
return;
}
}
}
self.parseData = data;
}];
[task resume];
if (self.parseDataAvailable) {
self.parseDataAvailable(self.parseData);
}
ParseTypeXML *myParser = [[ParseTypeXML alloc] initWithData:self.parseData];
if ([myParser.esn count] == 0) {
_passESN = @"Error";
} else {
_passESN = myParser.esn[0];
}
}
- (void)requireLogin {
LAContext *context = [[LAContext alloc] init];
NSError *error = nil;
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
// Authenticate User
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@"You must log in to the app."
reply:^(BOOL success, NSError * _Nullable error) {
if (success) {
self.finished = true;
if (self.touchIDWorks){
self.touchIDWorks(self.finished);
}
[self requestSession];
[self readIntSession];
[self checkIntSession:self.sessionDetail];
} else {
switch (error.code) {
case LAErrorAuthenticationFailed:
break;
case LAErrorUserCancel:
break;
case LAErrorUserFallback:
break;
default:
break;
}
}
}];
} else {
}
}
- (void)dataIsThere:(void (^)(NSData *foundData))finishBlock {
self.parseDataAvailable = finishBlock;
}
- (void)thumbOK:(void (^)(BOOL success))finishBlock {
self.touchIDWorks = finishBlock;
}
- (void)esnIsHere:(void (^)(NSString *newESN))finishBlock {
self.getUserESN = finishBlock;
}
- (void)esnIsReady:(void (^)(NSString *))finishBlock {
self.findUserESN = finishBlock;
}
- (void)fileReady:(void (^)(BOOL))finishBlock {
self.fileExistsNow = finishBlock;
}
それはViewController.mから呼び出されます。
- (IBAction)getESN:(id)sender {
Security *pulledESN = [[Security alloc] init];
self.gottenESN = [pulledESN retrieveESN];
self.responseLabel.text = self.gottenESN;
}
===その後
が完了ブロックに置く===を追加し、問題を解決していません。 requireLogin successセクションを完了した後でもコードはハングアップしているようです。私はリターンや何かが必要なように。
ありがとう、ルー。いいアイデアだね。確認してみるよ。 –
Lou、すべてのwhileループを完了ブロックに変更しました。同じ問題が起こっています。その他の提案はありますか?ご協力ありがとうございました。 –