从我的应用程序进行FaceTime音频通话

时间:2014-05-06 13:46:33

标签: ios ios7 facetime

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

3 个答案:

答案 0 :(得分:5)

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

感谢上面的回复,但是url方案适用于FaceTime视频,而非请求的音频。

答案 1 :(得分:1)

您可以将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
}

答案 2 :(得分:0)

用于FaceTime音频呼叫的本机应用URL字符串(仅适用于iOS):

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

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

尽管所有设备都支持此功能,但由于openURL:已过时,您必须为iOS 10.0及更高版本稍作更改代码。

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");
        }   
    }
  }

contactNumber中的通过电话号码或小程序。

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