0

I updated Firebase Dynamic Link pod to 1.4 version. In this version I found very useful class named FIRDynamicLinkComponents. I decided to use it to generate dynamic links. But I have 2 problems:

  1. Firebase doc says that dynamic links can survive installation process and open app on the content I described in dynamic link after installation from AppStore. It is not work.
  2. When user without installed app taps on dynamic links, he will see strange screen with button "Open in App". After click AppStore appears.

enter image description here Can we skip this screen?

My implementation:

static func createDynamicLinks(forChallangeId challangeId: String, authorId: String, authorEmail: String, completion: @escaping (_ dynamicLink: String?, _ error: Error?) -> Void) {
    let link = URL(string: "https://CODE.app.goo.gl/challange/\(challangeId)/author/\(authorId)")!
    let domain = DOMAIN
    let components = FIRDynamicLinkComponents(link: link, domain: domain)

    //add iOS params
    let iOSParams = FIRDynamicLinkIOSParameters(bundleID: bundleId)
    iOSParams.appStoreID = APP_STORE_ID
    components.iOSParameters = iOSParams

    //add Android params
    let androidParams = FIRDynamicLinkAndroidParameters(packageName: PACKAGE_NAME)
    androidParams.minimumVersion = 19
    components.androidParameters = androidParams

    //add social meta tag params
    let socialParams = FIRDynamicLinkSocialMetaTagParameters()
    socialParams.title = "You got new challenge"
    socialParams.descriptionText = "\(authorEmail) sent the challenge to you."
    socialParams.imageURL = IMAGE_URL
    components.socialMetaTagParameters = socialParams

    //add options
    let options = FIRDynamicLinkComponentsOptions()
    options.pathLength = .short
    components.options = options

    //make link shorter
    components.shorten { (shortURL, warnings, error) in
        if let error = error {
            completion(nil, error)
            return
        }
        guard let shortLinkString = shortURL?.absoluteString else {
            completion(nil, error)
            return
        }

        completion(shortLinkString, error)
    }
}

Edit

3rd problem.

Target iOS10. Handle:

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
    guard let dynamicLinks = FIRDynamicLinks.dynamicLinks() else {
        return false
    }

    let handled = dynamicLinks.handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
        if let url = dynamiclink?.url {
            DynamicLinksManager.handleDeepLink(link: url)
        }
    }

    return handled
}

handled is true but in closure dynamiclink and error are nil.

Kamil Harasimowicz
  • 4,684
  • 5
  • 32
  • 58
  • Can you edit your answer to include your implementation of the AppDelegate's application(_ application: UIApplication, open url: URL) and/or application(_ application: UIApplication, continue userActivity:)? – Jen Person May 05 '17 at 15:03
  • I added new info to question. Maybe it helps. – Kamil Harasimowicz May 05 '17 at 15:19
  • Thank you! Nothing sticks out to me right away as the cause. Does this also happen when you follow the basic Firebase-generated Dynamic Link to take you to the app? Try that out as a means to eliminate some of the variables that could cause the problem. Also, it's ok if it doesn't call openUrl. If you're on iOS 10, it will just call continueUserActivity. If you're not on iOS 10, then yeah I suppose that's a problem. – Jen Person May 05 '17 at 15:21
  • my target is iOS 10 – Kamil Harasimowicz May 05 '17 at 15:24
  • I edited question again. – Kamil Harasimowicz May 05 '17 at 15:38
  • Thanks for the info! I'd try the Firebase-generated Dynamic Link Domain first. That will tell you if the issue is with the custom generated links or not, which will narrow down the problem a lot. – Jen Person May 05 '17 at 15:41

1 Answers1

0

A lot of solutions depend on having more context than you've currently included. I'll edit this answer with updates as possible.

  1. Dynamic Links definitely can survive the installation process in most situations. However, there are a lot of edge cases. Could you add specific reproduction steps for exactly the process you're using to test?
  2. No, unfortunately this modal cannot be skipped. Apple made some changes in iOS 10.3 that make something like this unavoidable (read here for more on what happened, and how we handled the same problem in a slightly more elegant way at Branch)
  3. This might be expected, if no valid Dynamic Link were triggered. Again, could you add specific reproduction steps?
Alex Bauer
  • 13,147
  • 1
  • 27
  • 44