Make a call from my iPhone application

后端 未结 3 1141
天命终不由人
天命终不由人 2021-01-06 03:38

I have implemented the ability to make a call from clicking on a row of descriptive tableview of my hotel; I used the URL scheme by writing the following code in method \"di

相关标签:
3条回答
  • 2021-01-06 04:13

    To expand on seanny94's answer: the simulator doesn't support a lot of iOS's URL schemes, including those for the Phone, Maps, Youtube, and SMS apps. This is also the case for devices like the iPod touch and the iPad, which don't have phone capabilities; before using any URL scheme via -openURL:, you should check for support for that scheme using -canOpenURL:, which will return YES or NO depending on whether the current device supports the URL scheme you're using.

    0 讨论(0)
  • 2021-01-06 04:20

    You can't test a phone call (or any phone-based function, for that matter) in the Simulator. There is no support for it.

    0 讨论(0)
  • 2021-01-06 04:30

    Try this useful code

    Remove spaces for your code

    NSString *trimmedString = [yourNumberString stringByReplacingOccurrencesOfString:@" " withString:@""];
    

    Code for Call after confirmation

    NSString *phoneNumber = [@"telprompt://" stringByAppendingString:trimmedString];
    

    Code for direct calling

    NSString *phoneNumber = [@"tel://" stringByAppendingString:trimmedString];
    NSLog(@"Number : %@",phoneNumber);
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
    
    0 讨论(0)
提交回复
热议问题