iOS撥打電話,發(fā)短息不彈框或多次彈問(wèn)題

iOS 10.2 之前,為了交互良好,在調(diào)用撥打電話之前會(huì)自己設(shè)置彈框;在IOS10.2之后系統(tǒng)做了改版,對(duì)App調(diào)用別的一些權(quán)限的時(shí)候系統(tǒng)會(huì)自己觸發(fā)彈框,所以需要分版本處理。
注:解決系統(tǒng)有的系統(tǒng)彈2次框,有的系統(tǒng)不彈框。

pragma mark -- 判定當(dāng)前的手機(jī)系統(tǒng)時(shí)候?yàn)镮OS10.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 -- 點(diǎn)擊電話操作

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

    }
    }

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容