Deep Links
CleverPush Deep Links
- Open the Project in Xcode.
- Select the project's main target.
- Select the info tab.
- Select the url type.
- Select the url scheme and enter the url scheme (Example :- cleverpush)
- Go to the button of any view controller from where we need to share the url to another user
@IBAction func btnHandlerShareURL(_ sender: Any) {
// From here user can share their own url to another user using the share activity (Example :- let path = "cleverpush://")
let path = "url://"
let textToShare = [ path ]
let activityViewController = UIActivityViewController(activityItems: textToShare, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
activityViewController.excludedActivityTypes = [ UIActivity.ActivityType.airDrop, UIActivity.ActivityType.postToFacebook ]
self.present(activityViewController, animated: true, completion: nil)
}
- Add the following code in your AppDelegate.swift file
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// From here we can check that url contains cleverpush or not?
if url.scheme == "cleverpush" {
let ab = UIStoryboard(name: "Main", bundle: nil)
let vc = ab.instantiateViewController(withIdentifier: "ViewController") as! ViewController
window?.rootViewController = vc
}
return true
}