Making phone calls from code

Discussion in 'iOS Programming' started by spiffers, Dec 3, 2010.

  1. spiffers Suspended

    Joined:
    Apr 12, 2009
    #1
    Im working on an app and I have to be able to make phone calls from within my app. I have googled it, but did not find anything. Maybe Im not searching for the right thing? Would love some pointers to how to make phone calls programmatically.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You use well documented tel: URL scheme. This will open the Phone app with the phone number entered. The user can then initiate the call or not. There is no alternate way to dial without user approval.
     
  3. yaniv92648, Dec 5, 2010
    Last edited by a moderator: Dec 6, 2010

    yaniv92648 macrumors member

    Joined:
    Oct 26, 2009
    #3
    Answer

    Code:
    [[UIApplication sharedApplication] OpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]];
     
  4. dejo, Dec 6, 2010
    Last edited: Dec 6, 2010

    dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Well, not exactly. Remember that Objective-C is case-sensitive and UIApplication has no OpenURL: instance method.
     
  5. yaniv92648 macrumors member

    Joined:
    Oct 26, 2009
    #5
    weird cuz i copied it from the code...

    but u'r right anyhow....
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    Did you copy it from working code?

    Where did you get that code from?
     
  7. yaniv92648, Dec 6, 2010
    Last edited by a moderator: Dec 6, 2010

    yaniv92648 macrumors member

    Joined:
    Oct 26, 2009
    #7
    From my own code..

    But somehow the o in openURL got bigger...
    this is the right one:
    Code:
    [[UIApplication sharedApplication] [COLOR="Red"]openURL[/COLOR]:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]];
     
  8. spiffers thread starter Suspended

    Joined:
    Apr 12, 2009

Share This Page