Launching Facetime from your app?

前端 未结 5 1024
忘掉有多难
忘掉有多难 2021-01-04 19:33

I am seeing that you can launch FaceTime from your app via

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@\"facetime://tel-number\"]];
         


        
5条回答
  •  盖世英雄少女心
    2021-01-04 19:58

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

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

    Please refer link : https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/FacetimeLinks/FacetimeLinks.html

    Though this feature is supported on all device , you have to change code 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 current and fallback mechanism, so in 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];
    

提交回复
热议问题