Dial a phone number with an access code programmatically in iOS

前端 未结 10 1106
既然无缘
既然无缘 2020-12-02 06:54

How can I dial a phone number that includes a number and access code programmatically in iOS?

For example:

number: 900-3440-567
Access C

相关标签:
10条回答
  • 2020-12-02 06:55
    UIDevice *device = [UIDevice currentDevice];
    if ([[device model] isEqualToString:@"iPhone"] ) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:130-032-2837"]]];
    } else {
        UIAlertView *notPermitted=[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Your device doesn't support this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [notPermitted show];
        [notPermitted release];
    }
    
    0 讨论(0)
  • 2020-12-02 06:55

    Using this user can redirect on Call and after the call he/she will automatically redirected to the app. It's working for me and sure about it.

    if ([[device model] isEqualToString:@"iPhone"] ) {
    
        NSString *phoneNumber = [@"telprompt://" stringByAppendingString:cellNameStr];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
    
    } else {
    
        UIAlertView *warning =[[UIAlertView alloc] initWithTitle:@"Alert" message:@"Your device doesn't support this feature." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    
        [warning show];
    }
    
    0 讨论(0)
  • 2020-12-02 06:56

    It's not possible to dial programmatically a phone number that includes number and access code.

    The Apple Developer Library gives the following info:

    "...the Phone application supports most, but not all, of the special characters in the tel scheme. Specifically, if a URL contains the * or # characters, the Phone application does not attempt to dial the corresponding phone number."

    See: Apple URL Scheme Reference

    0 讨论(0)
  • 2020-12-02 07:02

    Swift 5.0: In case someone needed an updated swift code:

    private func callNumber(phoneNumber:String) {
        if let phoneCallURL:NSURL = NSURL(string: "tel://\(phoneNumber)") {
            let application:UIApplication = UIApplication.shared
            if (application.canOpenURL(phoneCallURL as URL)) {
                if #available(iOS 10.0, *) {
                    UIApplication.shared.open(phoneCallURL as URL)
                } else {
                    UIApplication.shared.openURL(phoneCallURL as URL)
                }
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-02 07:04

    You can programmatically dial phone numbers using UIApplication's openURL: method (see example below). I'm unsure if access codes are supported, but this is at least a starting point.

    NSURL *URL = [NSURL URLWithString:@"tel://900-3440-567"];
    [[UIApplication sharedApplication] openURL:URL];
    

    Edit: See the Apple URL Scheme Reference and the UIApplication Class Reference for more information.

    0 讨论(0)
  • 2020-12-02 07:05

    follow the tutorial

    http://www.makebetterthings.com/blogs/iphone/open-phone-sms-email-map-and-browser-apps-in-iphone-sdk/

    to call a number use -

    NSURL *url = [NSURL URLWithString:@"tel://012-4325-234"];
    [[UIApplication sharedApplication] openURL:url];
    

    to open your app after call finished use -

    (Note: telprompt is undocumented)

    NSURL *url = [NSURL URLWithString:@"telprompt://012-4325-234"];
    [[UIApplication sharedApplication] openURL:url];
    
    0 讨论(0)
提交回复
热议问题