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?
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.
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
}
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];
© 2022 - 2024 — McMap. All rights reserved.