Swiftpack.co - AppCraftTeam/appcraft-dynamic-links-ios as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by AppCraftTeam.
AppCraftTeam/appcraft-dynamic-links-ios 0.0.4
Dynamic Links Service
⭐️ 0
🕓 4 days ago
.package(url: "https://github.com/AppCraftTeam/appcraft-dynamic-links-ios.git", from: "0.0.4")


Handy dynamic links manager based of Firebase Dynamic Links.



  • IOS 11 or above
  • Xcode 12.5 or above


  1. Go to File -> Swift Packages -> Add Package Dependency...
  2. Then search for
  1. Select the SDK version that you want to use

How to use

  1. Create your own PathType enum, something like:
enum PathType: String {
    case mainScreen
    case settingsScreen
    case unknown
  1. Create an instance of GenerationData: GenerationDataProvider
let generationData = GenerationData(urlStringPrefix: "https://www.mywebsite.com/", // fallback URL
                                    domainURLPrefix: "https://myapp.page.link", // from firebase console
                                    iOSBundle: Bundle.main.bundleIdentifier ?? "com.myiosapp.isnice",
                                    appStoreID: "1337133713", // might not work without it
                                    androidBundle: "com.myandroidapp.isnice") // to provide cross-platform compatibility
  1. Initialize ACDynamicLink in AppDleegate's didFinishLaunchingWithOptions and store its reference:
dynamicLink = ACDynamicLink(generationData: generationData)
  1. Implement AppDelegate's methods to receive and handle dynamic links
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    let canOpenURL = dynamicLink.readFromURL(url) { path in
        // handle nav path
    return canOpenURL

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
    let canOpenURL = dynamicLink.readFromUserActivity(userActivity) { path in
        // handle nav path
    return canOpenURL

Example of handling nav path:

func handleNavPath(_ navPath: NavigatablePath?) {
    guard let navPath = navPath else { return }
    let appNavPath = AppNavPath(navigatablePath: navPath)
    guard appNavPath.type != .unknown else { return }
    switch appNavPath.type {
    case .mainScreen:
        // push/present whatever you need
    case .settingsScreen:
        // push/present whatever you need
    case .unknown:
        // push/present whatever you need

struct AppNavPath {
    let type: PathType
    let id: String?
    init(navigatablePath: NavigatablePath) {
        self.type = PathType(rawValue: navigatablePath.pathSuffix) ?? .unknown
        self.id = navigatablePath.id
  1. To create a link:
dynamicLink.generate(pathSuffix: String, id: String?, completion: @escaping (URL?) -> Void)

Example of creating a link

func generateLink(path: AppNavPath) {
    dynamicLink.generate(pathSuffix: path.type.rawValue, id: path.id) { [weak self] url in
        // example of sharing a link
        guard let url = url else { return }
        let vc = UIActivityViewController(activityItems: [url.absoluteString], applicationActivities: nil)
        vc.popoverPresentationController?.sourceView = self?.view
        vc.modalPresentationStyle = .fullScreen
        self?.present(vc, animated: true)

There is an [Example project](https://raw.github.com/AppCraftTeam/appcraft-dynamic-links-ios/main//Example project) to help you figure it all out.


Do not forget to set up Firebase Console and add GoogleService-Info.plist to your project

If your project already has Firebase framework installed, you will face crashes as ACDynamicLink already contains that dependency. Remove the original dependency to avoid crashes.


Distributed under the MIT License.


Email: [email protected]


Stars: 0
Last commit: 5 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Demo's dependency versioning
1 year ago

Set Example Project's ACDynamicLink dependency to .upToNextMajor

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics