Search code examples
iosswiftfirebasefirebase-in-app-messaging

Firebase In-app messaging button action doesn't work


In my iOS project, I have setup all the dependencies for firebase in-app messaging and on the button click I need to take the user to a webpage.

The banner and the message is getting received in the device as required, but the button action doesn't open the web page.

Please note that the same work for android app without any issue, it opens the url in the browser without any issue.

I'm sending the URL in the correct format ie : https://www.something.com

Please anyone can show some light on this?


Solution

  • Okay,the solution is to use firebase dynamic links and add a method in AppDelegate.swift

    func application(_ application: UIApplication,
                   open url: URL,
                   sourceApplication: String?,
                   annotation: Any) -> Bool {
    let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url)
    
    if dynamicLink != nil {
      if dynamicLink?.url != nil {
        // Handle the deep link. For example, show the deep-linked content,
        // apply a promotional offer to the user's account or show customized onboarding view.
        // ...
      } else {
        // Dynamic link has empty deep link. This situation will happens if
        // Firebase Dynamic Links iOS SDK tried to retrieve pending dynamic link,
        // but pending link is not available for this device/App combination.
        // At this point you may display default onboarding view.
      }
      return true
    }
    return false
    }
    

    check more in in-app messaging sample from google