简体   繁体   中英

Can't use FaceTime from app

I'm writing an App where you can call a person via FaceTime. My problem is, when I click on my button for the FaceTime-call, FaceTime opens but there is always a message "animStartXXXXXXX is not available for FaceTime." (the XXXX are random numbers). If I then call the same person from the normal FaceTime-app it works. The code for the FaceTime-call:

 NSString *facetimeString = @"facetime://";
[facetimeString stringByAppendingString:contactNumber];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:facetimeString]];

I get the contactNumber by selecting it from the Adressbook from within my App and it works fine with normal calls/SMS. Does anyone have a solution for my problem?

I don't think PAIR is using FaceTime for video chat.

Since FaceTime API is not available to developers, you should consider using OpenTok iOS SDK .

Here is a excerpt from GitHub site:

The OpenTok iOS SDK lets you use OpenTok video sessions in apps you build for iPad, iPhone, and iPod touch devices. This means you can use OpenTok video sessions that connect iOS users with each other and with web clients.

It is official that you can use Native app URL strings for FaceTime video calls:

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

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 and above as 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

          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 contactNumber either pass phone number or appleid.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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