Detecting whether or not device support phone calls?

后端 未结 9 2164
别跟我提以往
别跟我提以往 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条回答
  •  萌比男神i
    2020-11-28 23:51

    The iPhone supports the tel:// URI scheme. So you could use:

    [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel://"]];
    

    canOpenURL: explicitly checks whether there's an application capable of opening that URL scheme, not that the URL is correct. So it doesn't matter that no phone number is specified. The method returns a BOOL, so check that for YES or NO.

    That should literally answer whether there's any application present capable of making a telephone call. So it should be okay against any future changes in device segmentation.

提交回复
热议问题