How make an outgoing call from my app?

故事扮演 提交于 2019-12-10 00:32:24

问题


i develop a calling program in the below way. my main aim is enter the number in textfield and whenever i press the call button it convert

into the integer and then perform calling action.in xcode is there any possibility to create a

code for outgoing call?

And is there any possibility to block the incoming calls?

i am writing the code below way.

my .h file is

@interface mytextViewController : UIViewController
{             
  IBOutlet UILabel *enterphonenumber;           
    int currentNumber;        
}

@property(nonatomic,retain)IBOutlet UILabel *enterphonenumber;

-(IBAction)call;

-(IBAction)press:(id)sender;

@end

my .m file is

-(IBAction)press:(id)sender    
{    
    currentNumber = currentNumber*10 + (int)[sender tag];

    enterphonenumber.text = [NSString stringWithFormat:@"%i",currentNumber];    
}    

-(IBAction)call

{        
    int x =[enterphonenumber.text intValue];       

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:x]];
//[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"%tel:9963610177"]];
    NSLog(@"sample %@",[NSURL URLWithString:@"my phone number is calling"]);
}

And also how to examine it performs a calling

please any one help because i am the new to develop this application

Thanking you,


回答1:


Try using the tel protocol.

if ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone"])
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%d", number]]];
}

You cannot block any incoming calls.




回答2:


You can't block any incoming calls in your app.



来源:https://stackoverflow.com/questions/9955038/how-make-an-outgoing-call-from-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!