Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make facetime call from Swift?

I am developing an app in Swift for iPad that makes use of facetime.

I know Apple introduced App projection (described about 3/4 of way down page) (where one app can "project" itsself into another) in iOS 8. Is facetime capable of this, and if so, how do I access this functionality in swift?

If not, how does one use facetime from an app programatically otherwise? I found this question about the Swift API that explained how to do it in objective C. How do I adapt that code to work in swift? When I use it as written, I get the error "Expected ; seperator"

Barring the above two, is there any other or better ways to program facetime functionality for a swift app?

Thanks!

like image 227
rocket101 Avatar asked Aug 04 '14 23:08

rocket101


People also ask

How do I make a call using FaceTime?

In the FaceTime app tap the plus button and type the person's phone number or email address. 2. Tap the number or address, then tap Audio or Video .

Can I FaceTime internationally for free?

The answer is yes! FaceTime is free whether you or the other person is outside the country. You can make international FaceTime calls and they are free as long as you have internet connectivity. But make sure to connect your iPhone to a Wi-Fi network.

How do you call internationally using FaceTime?

Open the FaceTime app, and enter the phone number or email address you want to call. If the person you want to call is in your Contacts app, you can simply type in the name. Then, just click the Audio button to make an audio-only call. During a call, you can switch to and from video calling.


2 Answers

Allow me to answer my own question...

I originally used the following code

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"facetime://tel-number"]];

With the help of this question, and the Apple Facetime API docs, I determined that the proper code was :

UIApplication.sharedApplication().openURL(NSURL(string: "facetime://tel-number"))

I hope this helps anyone else in the future.

like image 77
rocket101 Avatar answered Oct 14 '22 11:10

rocket101


A bit more self-contained solution in Swift:

private func facetime(phoneNumber:String) {
  if let facetimeURL:NSURL = NSURL(string: "facetime://\(phoneNumber)") {
    let application:UIApplication = UIApplication.sharedApplication()
    if (application.canOpenURL(facetimeURL)) {
      application.openURL(facetimeURL);
    }
  }
}

Now, you should be able to use facetime("7178881234") to make a facetime call.

like image 21
Zorayr Avatar answered Oct 14 '22 11:10

Zorayr