I'm trying to override Firebase's default behavior for opening the link from the In-App-Messaging following this guide:
https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=ios
I set the delegate of InAppMessaging in AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
InAppMessaging.inAppMessaging().delegate = self
}
I add my logic in the Delegate method:
extension AppDelegate: InAppMessagingDisplayDelegate {
func messageClicked(_ inAppMessage: InAppMessagingDisplayMessage, with action: InAppMessagingAction) {
let topMostViewController = UIApplication.shared.topMostViewController()
//openUrl has logic for opening the url inside the app in a full screen webview FullScreenWKWebView, this works great
openUrl(action.actionURL, parent: topMostViewController)
}
When tapping the button in the InAppMessaging message the delegate method messageClicked is loaded perfectly and also the logic for opening the url inside the app works. BUT also the default logic from Firebase for opening the link continues so the url is opening inside the app and at the same time Firebase jumps out of the app and open the url in Safari.
Is there some way I can cancel the default logic from Firebase so that it only opens inside the app?
For HTTP links, you can intercept URL opening in the handoff:
// UIApplicationDelegate
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// handle userActivity.webpageURL
// true, if handled
return true
}