Detecting whether or not device support phone calls?

后端 未结 9 2162
别跟我提以往
别跟我提以往 2020-11-28 23:13

Is the below code reliable to be used to determine whether a device can support phone calls or not? My concern is if apple changes the iphone string to anything else let\'s

9条回答
  •  孤城傲影
    2020-11-29 00:07

    In case you are asking in order to call a phone number and show an error on devices that have no telephony:

    void openURL(NSURL *url, void (^ __nullable completionHandler). (BOOL success))
    {
        if (@available(iOS 10.0, *)) {
            [application openURL:url options:@{} completionHandler:^(BOOL success) {
                completionHandler(success);
            }];
        } else
        {
            if([application openURL:url]) {
                completionHandler(YES);
            } else {
                completionHandler(NO);
            }
        }
    }
    

    usage

            p97openURL(phoneURL, ^(BOOL success) {
                if(!success) {
                      show message saying there is no telephony on device
    
                }
            }
    

提交回复
热议问题