Ios 使用OpenUrl时如何处理默认警报tel://2373829239

Ios 使用OpenUrl时如何处理默认警报tel://2373829239,ios,objective-c,Ios,Objective C,运行此命令后,我会收到两个按钮的警报,分别为call和cancel。 呼叫按钮将导航到拨号板并拨打正常的电话。但是我想在单击取消按钮时执行一些操作 这是我的密码 从上面的评论中我得到了答案。 //对于iPhone,请使用以下命令: if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",phoneNumber]]])

运行此命令后,我会收到两个按钮的警报,分别为call和cancel。 呼叫按钮将导航到拨号板并拨打正常的电话。但是我想在单击取消按钮时执行一些操作

这是我的密码


从上面的评论中我得到了答案。 //对于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)
}

从上面的评论中我得到了答案。 //对于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)
}

这是你无法避免的。我想对取消按钮事件执行一些操作。你看过使用
了吗telprompt://1234567890“
而不是
”tel://
?完成块在取消时返回false…谢谢。完成处理程序对我有效。“telprompt://”和“tel://“不会有任何区别。这是你无法避免的。我想对取消按钮事件执行一些操作。你看过使用
了吗?”telprompt://1234567890“
而不是
”tel://
?完成块在取消时返回false…谢谢。完成处理程序对我有效。“telprompt://”和“tel://”没有任何区别。