TUSafariActivity
is a UIActivity
subclass that provides an "Open In Safari" action to a UIActivityViewController
.
TUSafariActivity is available through Swift Package Manager. To install
it, simply add the following line to your Package.swift
:
dependencies: [.package(url: "https://github.com/davbeck/TUSafariActivity.git", from: "1.0.0")]
TUSafariActivity is available through CocoaPods. To install
it, simply add the following line to your Podfile
:
pod 'TUSafariActivity', '~> 1.0'
(See example Xcode project)
Simply alloc
/init
an instance of TUSafariActivity
and pass that object into the applicationActivities array when creating a UIActivityViewController
.
NSURL *URL = [NSURL URLWithString:@"http://google.com"];
TUSafariActivity *activity = [[TUSafariActivity alloc] init];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[URL] applicationActivities:@[activity]];
let url = URL(string: "http://google.com")!
let activity = TUSafariActivity()
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: [activity])
Note that you can include the activity in any UIActivityViewController
and it will only be shown to the user if there is a URL in the activity items.