Crash when use UIWebview on iPad and iPhone running iOS 10.0 on Wi-Fi connected to an IPv6 network

北战南征 提交于 2020-01-23 17:43:44

问题


Iphone app rejected because of the the reason that “We discovered one or more bugs in your app when reviewed on iPad and iPhone running iOS 10.0 on Wi-Fi connected to an IPv6 network.” Anyone can help to solve it?

First time when my application load. It need to push notification to server:

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{

     NSString *token = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
     token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
     NSLog(@"Device token is: %@", token);

     NSString *globalToken = [Util objectForKey:@"globalToken"];
     if (globalToken) {
          if ([token isEqualToString:globalToken]) {
               return;
          }
     }

     [Util setObject:token forKey:@"globalToken"];

     NSString *urlString = [NSString stringWithFormat:@"http://api.xosovietnam.vn/ApiPushDevices/save?secret=06btF1Q&platform=IOS&token=%@", token ];
     NSLog(@"%@", urlString);

     NSURLSessionConfiguration *conf = [NSURLSessionConfiguration defaultSessionConfiguration];
     NSURLSession *session = [NSURLSession sessionWithConfiguration:conf];

     NSURL *URL = [NSURL URLWithString:urlString];
     NSURLRequest *urlRequest = [NSURLRequest requestWithURL:URL];

     NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:urlRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

          ResponseObject *responseObj = [[ResponseObject alloc] init];

          if (!error) {
               NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
               if (httpResponse.statusCode == 200) {
                    NSLog(@"Success Push Token.");


               }
          }else{
               responseObj.error = error;

               dispatch_async(dispatch_get_main_queue(), ^{

                    if (error.code == -1009 || error.code == -1004 || error.code == -1003 || error.code == -1005) {
                         NSLog(@"The Internet connection appears to be offline.");
                         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Để sử dụng app cần có mạng internet" delegate:nil cancelButtonTitle:@"Huỷ" otherButtonTitles: nil];
                         [alert show];

                    }else{
                         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:[NSString stringWithFormat:@"%@", error.localizedDescription] delegate:nil cancelButtonTitle:@"Huỷ" otherButtonTitles: nil];
                         [alert show];
                    }

                    return ;

               });
          }
     }];

     [dataTask resume];
}

After that. I create an UIWebview to load my website:

- (void)viewDidLoad {
     [super viewDidLoad];

     self.automaticallyAdjustsScrollViewInsets = NO;

     if ([self.myWebView respondsToSelector:@selector(setKeyboardDisplayRequiresUserAction:)]) {
          self.myWebView.keyboardDisplayRequiresUserAction = NO;
     }

     NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://xosovietnam.vn/"]];
     [self.myWebView loadRequest:req];

}

Someone can help me please. This is second time I get reject when I subit my application.


回答1:


From your code there are two things to consider.

1) UIWebView is deprecated. WKWebView is recommended by Apple.

2) You are loading an HTTP request. If you are using Xcode 8, I think you may need to add some exceptions for WKWebView. "NSAllowArbitraryLoad" is still not enough.



来源:https://stackoverflow.com/questions/39522607/crash-when-use-uiwebview-on-ipad-and-iphone-running-ios-10-0-on-wi-fi-connected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!