【问题标题】:How to catch error that iPad make phone call get error "iPhone calls not available"如何捕捉 iPad 拨打电话的错误“iPhone 通话不可用”
【发布时间】:2020-05-05 06:54:53
【问题描述】:

我有一个关于使用 iPad 打电话的问题。
我尝试拨打电话,但系统在 iPad 中出现错误。
如何控制如下图所示的错误消息?
如何捕捉这个错误?
谢谢。

NSString *value = [NSString stringWithFormat:@"%@", phoneText];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",value]] options:@{} completionHandler:nil];

【问题讨论】:

    标签: ios objective-c swift phone-call openurl


    【解决方案1】:

    在调用函数openURL:options:completionHandler:之前,您可以使用函数canOpenURL:。您可以找到reference here

    在您的情况下,该函数将返回 false,您可以提供回退。

    
    NSString *value = [NSString stringWithFormat:@"%@", phoneText];
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",value]];
    
    if (url && [[UIApplication sharedApplication] canOpenURL: url]) {
        [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
    } else {
        // your fallback - you can display an alert controller
    }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-20
      • 1970-01-01
      • 2011-04-08
      • 2011-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多