ARDeepLinkButton
Overview
ARDeepLinkButton
is an UIButton
subclass that handle deep links, shows in-app SKStoreProductViewController
or redirects to the AppStore. Written in Swift 2.0
Installation
ARDeepLinkButton
is available through CocoaPods. To install
it, simply add the following line to your Podfile
:
pod "ARDeepLinkButton"
Swift Package Manager:
Or you can install it with.Package(url: "ssh://git@github.com:alexruperez/ARDeepLinkButton.git", versions: Version(1,0,0)..<Version(2,0,0)),
Carthage:
Or you can install it withgithub "alexruperez/ARDeepLinkButton"
Or you can add the following files to your project:
ARDeepLinkButton.swift
ARDeepLinkHandler.swift
Usage
ARDeepLinkButton
is @IBDesignable
and has the following properties:
@IBInspectable public var deepLink: String? // Example: "madbike://"
@IBInspectable public var iTunesURL: String? // Example: "https://itunes.apple.com/us/app/madbike/id1067596651?mt=8"
@IBInspectable public var cornerRadius: CGFloat // UIButton corner radius.
@IBInspectable public var borderWidth: CGFloat // UIButton border width.
@IBInspectable public var borderColor: UIColor? // UIButton border color.
@IBInspectable public var imageContentMode: Int // UIButton image UIViewContentMode value. Example: 1 for .ScaleAspectFit
@IBInspectable public var imageCornerRadius: CGFloat // UIButton image corner radius.
public lazy var deepLinkHandler = ARDeepLinkHandler() // Deep link handler, here you have access to SKStoreProductViewController in order to customize it.
public private(set) var appStoreId: String? // Automatically generated when iTunesURL is setted.
ARDeepLinkHandler
can be used independently and has the following public methods:
public func handle(deepLink: String?, appStoreId: String?, iTunesURLString: String?) -> Bool
public func handle(appStoreId: String?, iTunesURLString: String?) -> Bool
public func handle(URLString: String?) -> Bool
iOS 9 Reminder
Add your deep link to LSApplicationQueriesSchemes
in your Info.plist
<key>LSApplicationQueriesSchemes</key>
<array>
<string>madbike</string>
</array>
Etc.
- Contributions are very welcome.
- Attribution is appreciated (let's spread the word!), but not mandatory.
Use it? Love/hate it?
Tweet the author @alexruperez, and check out alexruperez's blog: http://alexruperez.com
License
ARDeepLinkButton is available under the MIT license. See the LICENSE file for more info.