美文网首页
iOS拨打电话,发短息不弹框或多次弹问题

iOS拨打电话,发短息不弹框或多次弹问题

作者: oneDemo | 来源:发表于2017-03-20 15:00 被阅读1378次

iOS 10.2 之前,为了交互良好,在调用拨打电话之前会自己设置弹框;在IOS10.2之后系统做了改版,对App调用别的一些权限的时候系统会自己触发弹框,所以需要分版本处理。
注:解决系统有的系统弹2次框,有的系统不弹框。

pragma mark -- 判定当前的手机系统时候为IOS10.2

  • (BOOL)validateCurrentMobileSystem10_2 {
    NSString *str2 = [[UIDevice currentDevice] systemVersion];
    if ([str2 compare:@"10.2" options:NSNumericSearch] == NSOrderedDescending || [str2 compare:@"10.2" options:NSNumericSearch] == NSOrderedSame) {
    return YES;
    }
    return NO;
    }

pragma mark -- 点击电话操作

  • (void)tapPhoneOperation:(UITapGestureRecognizer *)tapGesture {
    if ([DGNSUtil validateCurrentMobileSystem10_2]) {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",COMPANYPHONENUM]]];
    }
    else {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:COMPANYPHONENUM message:nil preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

      }];
      UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
          [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",COMPANYPHONENUM]]];
      }];
      [okAction setValue:COLORRPLUS forKey:@"_titleTextColor"];
      [cancelAction setValue:COLORFONTBLACK forKey:@"_titleTextColor"];
      
      [alertController addAction:cancelAction];
      [alertController addAction:okAction];
      [self presentViewController:alertController animated:YES completion:nil];
    

    }
    }

相关文章

网友评论

      本文标题:iOS拨打电话,发短息不弹框或多次弹问题

      本文链接:https://www.haomeiwen.com/subject/lozbnttx.html