3

Is there anyway I can get my app to appear when I click the share button on a video in the youtube app on ios?

I know how to add my app to the open in option, by adding my doc types to Info.plist file, but is there a way to do something similar when the share button is pressed in the youtube app on ios?

Similar to android question answered here.

android youtube: share a youtube video TO my app?

Community
  • 1
  • 1
omgpython
  • 241
  • 1
  • 4
  • 15

2 Answers2

7

Done with me I can share videos opened on Youtube App or Safari

Starting from iOS 8 this became possible with App Share Extension

If you are using SLComposeViewController you will get the URL using

self.contentText

and if you created your custom UIViewController

if([itemProvider hasItemConformingToTypeIdentifier:@"public.plain-text"]) {
            NSLog(@"itemprovider = %@", itemProvider);

            [itemProvider loadItemForTypeIdentifier:@"public.plain-text" options:nil completionHandler: ^(id<NSSecureCoding> item, NSError *error) {

                NSString *url;
                if([(NSObject*)item isKindOfClass:[NSString class]]) {
                    url = (NSString*)item;
                }
            }];
}
else if([itemProvider hasItemConformingToTypeIdentifier:@"public.url"]){
      [itemProvider loadItemForTypeIdentifier:@"public.url" options:nil completionHandler: ^(NSUrl *url, NSError *error) {

                NSString *url = [url absoluteString];


            }];
}

You can achieve that by making a Share Extension app that accepts links in general and If you want youtube links only you can filter the coming link with a regex.

enter image description here enter image description here

When using Youtube iOS app and sharing any video by pressing more opens iOS native action sheet I made a share extension to my app and it showed up in the sharing options.

When my app is selected i receive a link to the video.

I used this regex "https?:\\/\\/(?:[0-9A-Z-]+\\.)?(?:youtu\\.be\\/|youtube\\.com\\S*[^\\w\\-\\s])([\\w\\-]{11})(?=[^\\w\\-]|$)(?![?=&+%\\w]*(?:['\"][^<>]*>|<\\/a>))[?=&+%\\w]*" to detect that the link is a youtube link then I used this regex "((?<=(v|V)/)|(?<=be/)|(?<=(\\?|\\&)v=)|(?<=embed/))([\\w-]++)" to detect the videoId from the link

References: ios8-share-extension-swift

sharing-code-between-original-ios-app-and-app-extension

Community
  • 1
  • 1
Mohamed Elkassas
  • 829
  • 1
  • 13
  • 33
2

Impossible..

First think how to put icon or your app Share option in to YouTube App..? I don't think you can do this in iOS.. because Sharing option Provide by YouTube we can not able to changes in to YouTube API or YouTube App. how to put icon or your app Share option in to YouTube App?

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • Thanks for the reply. Well I know there is no such feature for share, if there were to be one, my icon would be there the same way it appears when you do an "Open With" from another app. – omgpython Jul 15 '13 at 20:05