9

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!

Community
  • 1
  • 1
rocket101
  • 7,369
  • 11
  • 45
  • 64
  • How did you try and write it in Swift? Let's start there rather than turning SO into a code translation service. – Abizern Aug 05 '14 at 00:38

2 Answers2

13

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.

Zorayr
  • 23,770
  • 8
  • 136
  • 129
6

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.

Climbatize
  • 1,103
  • 19
  • 34
rocket101
  • 7,369
  • 11
  • 45
  • 64