从应用内的 Firebase In-App-Messaging 打开 url
Open url from Firebase In-App-Messaging inside app
我正在尝试覆盖 Firebase 的默认行为,以便按照本指南从应用内消息中打开 link:
https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=ios
我在AppDelegate中设置了InAppMessaging的委托:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
InAppMessaging.inAppMessaging().delegate = self
}
我在 Delegate 方法中添加我的逻辑:
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)
}
当点击 InAppMessaging 消息中的按钮时,委托方法 messageClicked 被完美加载,并且在应用程序中打开 url 的逻辑也有效。但是 Firebase 打开 link 的默认逻辑也会继续,因此 url 在应用程序内部打开,同时 Firebase 跳出应用程序并在 Safari 中打开 url。
有什么方法可以取消 Firebase 的默认逻辑,使其仅在应用程序内部打开?
对于HTTP链接,可以拦截URL在切换中打开:
// UIApplicationDelegate
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// handle userActivity.webpageURL
// true, if handled
return true
}
我正在尝试覆盖 Firebase 的默认行为,以便按照本指南从应用内消息中打开 link:
https://firebase.google.com/docs/in-app-messaging/modify-message-behavior?platform=ios
我在AppDelegate中设置了InAppMessaging的委托:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
InAppMessaging.inAppMessaging().delegate = self
}
我在 Delegate 方法中添加我的逻辑:
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)
}
当点击 InAppMessaging 消息中的按钮时,委托方法 messageClicked 被完美加载,并且在应用程序中打开 url 的逻辑也有效。但是 Firebase 打开 link 的默认逻辑也会继续,因此 url 在应用程序内部打开,同时 Firebase 跳出应用程序并在 Safari 中打开 url。
有什么方法可以取消 Firebase 的默认逻辑,使其仅在应用程序内部打开?
对于HTTP链接,可以拦截URL在切换中打开:
// UIApplicationDelegate
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// handle userActivity.webpageURL
// true, if handled
return true
}