MrTung / MTCheckNewVersion

一句代码检测新版本
6 stars 2 forks source link

ios10下点击更新无效 #1

Open allran opened 7 years ago

allran commented 7 years ago

1.方法一: 把canOpenURL改为openURL

 [alert addAction:[UIAlertAction actionWithTitle:@"更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.appInfo.trackViewUrl]];

        }]];

2.方法二: 根据ios10的新api判断处理

allran commented 7 years ago
        [alert addAction:[UIAlertAction actionWithTitle:@"更新" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            if (([[[UIDevice currentDevice] systemVersion] doubleValue] >= 10.0)) {
                [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.appInfo.trackViewUrl] options:@{UIApplicationOpenURLOptionsOpenInPlaceKey:@"1"} completionHandler:^(BOOL success) {

                }];
            }else{
                if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:self.appInfo.trackViewUrl]]) {
                    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.appInfo.trackViewUrl]];
                }
            }
        }]];