4

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?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
ashif-ismail
  • 1,037
  • 17
  • 34
  • 1
    firebase in app messaging doesnt require any code setup.. – ashif-ismail Sep 26 '18 at 10:36
  • It would be helpful to know what data was sent and received and the the code showing what is done with that data once it's received. – Jay Sep 26 '18 at 16:18
  • 1
    i just set a http link to a website on button action in the firebase console,no additional code was required in the app other than setting dependencies,which works in android perfectly.but in ios it displays the in-app message but the click doesnt open the site – ashif-ismail Sep 27 '18 at 03:47
  • 1
    I also have the same problem on iOS! – Simon Ho Sep 28 '18 at 00:12

3 Answers3

2

I had this problem ever since In-App Messaging Launched. I do android part without any problem but for iOS, i cannot get the button work. Thank to the insight from this post. But the above addition alone to the AppDelegate do not work. I have to add more:

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
}



func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
    let handled = DynamicLinks.dynamicLinks().handleUniversalLink(userActivity.webpageURL!) { (dynamiclink, error) in
        // ...
    }

    return handled

}
Simon Ho
  • 588
  • 1
  • 8
  • 21
0

Make sure your AppDeletegate’s application:openURL:sourceApplication:annotation: (iOS 8 and older) and application:openURL:options: (iOS 9 and up) returns YES/true or NO/false correctly. In-App Messaging SDK would check the return value from these methods to decide if they are already handled by the app or not.

So for web link case, make sure you return No/false so that In-App Messaging SDK could forward it the system to be loaded in browser. You can debug this behavior by checking how your appdelegate' url handling method is being triggered after the button is clicked.

Yong
  • 21
  • 1
  • In your posted answer, the key thing is to return false at the end of the AppDelegate's method so that sdk knows that the url link has not been handled by the app and should be handled over to iOS as a web link. – Yong Sep 27 '18 at 20:17
0

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

ashif-ismail
  • 1,037
  • 17
  • 34
  • Im curious as to how you managed to get the button action working, i've tried everything from universal links (regular websites) to dynamic links (comgooglemaps://?saddr=&daddr=38.376100,-96.851619&directionsmode=driving) google maps nothing at all happens – CharlesAE Oct 17 '18 at 07:28
  • 1
    i think this issue only happens when you test with your instance ID, found in the console.i got it working without any change in the code by publishing an actual campaign(not just test) and then sending dynamic link,it works – ashif-ismail Oct 18 '18 at 06:01
  • true for me also ... action button doesn't work while testing , it do works on actual campaign – Luca Rocchi Nov 14 '18 at 09:33