Make a FaceTime audio call from my app
Asked Answered
B

3

5

I have a phone number or email address associated with a FaceTime account how can I initiate a FaceTime audio call from within my app?

Bartel answered 6/5, 2014 at 13:46 Comment(0)
B
5

Turns out the url scheme is facetime-audio://

Thanks for the response above but that url scheme is for FaceTime video, not audio as requested.

Bartel answered 7/5, 2014 at 0:35 Comment(0)
P
2

You can use Apple's Facetime URL Scheme for this

URL Schemes:

// by Number
facetime://14085551234

// by Email
facetime://[email protected]

Code :

NSString *faceTimeUrlScheme = [@"facetime://" stringByAppendingString:emailOrPhone];
NSURL    *facetimeURL       = [NSURL URLWithString:ourPath];

// Facetime is available or not
if ([[UIApplication sharedApplication] canOpenURL:facetimeURL])
{
    [[UIApplication sharedApplication] openURL:facetimeURL];
}
else
{
    // Facetime not available
}
Placket answered 6/5, 2014 at 13:51 Comment(0)
O
1

Native app URL strings for FaceTime audio calls (iPhone to iPhone calls only):

facetime-audio:// 14085551234
facetime-audio://[email protected]

Please refer to the link: https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/FacetimeLinks/FacetimeLinks.html

Though this feature is supported on all devices, you have to change the code a little bit for iOS 10.0 & above because openURL: is deprecated.

https://developer.apple.com/documentation/uikit/uiapplication/1622961-openurl?language=objc

Please refer code below for the current and fallback mechanism, so this way it will not get rejected by Appstore.

-(void) callFaceTime : (NSString *) contactNumber
{
    NSURL *URL = [NSURL URLWithString:[NSString
                  stringWithFormat:@"facetime://%@",  contactNumber]];
    if (@available(iOS 10.0, *)) {
        [[UIApplication sharedApplication] openURL:URL options:@{}
         completionHandler:^(BOOL success)
         {
         if (success)
         {
            NSLog(@"inside success");
         }
         else
         {
            NSLog(@"error");
         }
         }];
    }
    else {
        // Fallback on earlier versions.
        //Below 10.0
        NSString *faceTimeUrlScheme = [@"facetime://"
                                        stringByAppendingString:contactNumber];
        NSURL    *facetimeURL       = [NSURL URLWithString:faceTimeUrlScheme];
        
        // Facetime is available or not
        if ([[UIApplication sharedApplication] canOpenURL:facetimeURL])
        {
            [[UIApplication sharedApplication] openURL:facetimeURL];
        }
        else
        {
            // Facetime not available
            NSLog(@"Facetime not available");
        }
    }
}

 

In phoneNumber, either pass phone number or appleID.

   NSString *phoneNumber = @"9999999999";
   NSString *appleId = @"[email protected]";
   [self callFaceTime:appleId];

Ophiuchus answered 22/4, 2020 at 17:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.