4

我有一个与 FaceTime 帐户关联的电话号码或电子邮件地址,如何从我的应用程序中发起 FaceTime 音频通话?

4

3 回答 3

5

原来 url 方案是 facetime-audio://

感谢上述回复,但该 url 方案适用于 FaceTime 视频,而不是要求的音频。

于 2014-05-07T00:35:47.530 回答
2

您可以为此使用 Apple 的Facetime URL Scheme

网址方案:

// by Number
facetime://14085551234

// by Email
facetime://user@example.com

代码 :

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
}
于 2014-05-06T13:51:07.560 回答
1

FaceTime 音频通话的本机应用程序 URL 字符串(仅限 iPhone 到 iPhone 通话):

facetime-audio:// 14085551234
facetime-audio://user@example.com

请参考链接:https ://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/FacetimeLinks/FacetimeLinks.html

尽管所有设备都支持此功能,但您必须稍微更改 iOS 10.0 及更高版本的代码,因为不推荐使用 openURL:。

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

请参考下面的代码了解当前和回退机制,这样它就不会被 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");
        }
    }
}

 

在 phoneNumber 中,传递电话号码或 appleID。

   NSString *phoneNumber = @"9999999999";
   NSString *appleId = @"abc@gmail.com";
   [self callFaceTime:appleId];

于 2020-04-22T17:34:06.410 回答