TUSafariActivity



## Introduction

Welcome to the documentation for TUSafariActivity! TUSafariActivity is a custom UIActivity subclass that adds a “Open in Safari” action to UIActivityViewController. This allows users to easily open a URL in Safari from your app. This documentation will guide you through the process of integrating TUSafariActivity into your project.



## Installation

To install TUSafariActivity, you have a few options:


### Manual Installation

1. Download the TUSafariActivity source files from [GitHub](https://github.com/davbeck/TUSafariActivity).
2. Drag and drop the downloaded source files into your Xcode project.


### CocoaPods Installation

1. Add the following line to your Podfile:

“`ruby
pod ‘TUSafariActivity’
“`

2. Run `pod install` command in your terminal.



## Usage

Using TUSafariActivity is straightforward. Follow the steps below to integrate it into your project:

1. Import `TUSafariActivity` in your source file:

“`swift
import TUSafariActivity
“`

2. Create an instance of `TUSafariActivity` with the desired title:

“`swift
let safariActivity = TUSafariActivity()
“`

3. Create an instance of `UIActivityViewController`, passing in the URL you want to open in Safari and the `TUSafariActivity` instance:

“`swift
let viewController = UIActivityViewController(activityItems: [url], applicationActivities: [safariActivity])
“`

4. Present the `UIActivityViewController`:

“`swift
present(viewController, animated: true, completion: nil)
“`



## Additional Customization

TUSafariActivity offers additional customization options:

1. To set a custom title for the activity, use the `TUSafariActivity` initializer:

“`swift
let safariActivity = TUSafariActivity(title: “Open in Safari”)
“`

2. You can also customize the activity’s icon by providing a custom image:

“`swift
let customImage = UIImage(named: “CustomIcon”)
let safariActivity = TUSafariActivity(icon: customImage)
“`

3. If you need to exclude specific types of activity, you can use the `excludedActivityTypes` property of `UIActivityViewController`:

“`swift
let excludedTypes: [UIActivity.ActivityType] = [.postToFacebook, .postToTwitter, .postToWeibo]
viewController.excludedActivityTypes = excludedTypes
“`



## Conclusion

You have now successfully integrated TUSafariActivity into your project! Users will be able to open URLs in Safari with ease. Feel free to explore the TUSafariActivity repository on [GitHub](https://github.com/davbeck/TUSafariActivity) for additional information and examples.

If you have any questions or need further assistance, don’t hesitate to reach out to our support team. Happy coding!