运行此操作后,我正在通过两个按钮作为通话获取警报并取消。 呼叫按钮将导航到拨号盘并拨打电话,这很好。但我想点击取消按钮执行一些操作。
这是我的代码。
NSString *urlString = [NSString stringWithFormat:@"tel:123"];
NSString *escaped = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:escaped]];
答案 0 :(得分:0)
从上面的评论我得到了答案。 //对于iPhone使用此:
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",phoneNumber]]])
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",phoneNumber]] options:@{} completionHandler:^(BOOL success)
{
{
if (success)
{
NSLog(@"inside call clikced");
}
else
{
NSLog(@"inside cancel clicked");
}
}
}];
}
// For iPad use this:
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier1 = [info subscriberCellularProvider];
if (carrier1.mobileCountryCode.length == 0 || carrier1.mobileCountryCode.length == nil)
{
// false for iPad Air 2(which doesn't have cellular Provider)
}