繁体   English   中英

从我的应用程序拨打 FaceTime 音频电话

[英]Make a FaceTime audio call from my app

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

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

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

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

URL 方案:

// 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
}

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];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM