【问题标题】:Crash when use UIWebview on iPad and iPhone running iOS 10.0 on Wi-Fi connected to an IPv6 network在连接到 IPv6 网络的 Wi-Fi 上运行 iOS 10.0 的 iPad 和 iPhone 上使用 UIWebview 时崩溃
【发布时间】:2016-09-16 01:31:26
【问题描述】:

Iphone 应用程序被拒绝,原因是“我们在通过连接到 IPv6 网络的 Wi-Fi 运行 iOS 10.0 的 iPad 和 iPhone 上审查时发现您的应用程序中存在一个或多个错误。”谁能帮忙解决一下?

第一次加载我的应用程序。它需要向服务器推送通知:

- (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];
}

之后。我创建了一个 UIWebview 来加载我的网站:

- (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];

}

请有人可以帮助我。这是我第二次在提交申请时被拒绝。

【问题讨论】:

  • Apple 发现的“一个或多个错误”是什么?
  • 我的网页浏览器无法加载。我不知道是什么原因。用于推送通知或我的网站链接错误的 API?我检测不出来。我尝试创建 NAT64 共享 wifi 以在我的 iPhone 上进行测试。但我不能得到任何错误。你有什么建议吗?

标签: ios uiwebview ipv6


【解决方案1】:

根据您的代码,有两件事需要考虑。

1) UIWebView 已弃用。 WKWebView 是 Apple 推荐的。

2) 您正在加载一个 HTTP 请求。如果您使用的是 Xcode 8,我认为您可能需要为 WKWebView 添加一些例外。 “NSAllowArbitraryLoad”仍然不够。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多