Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong thread when invoking webview #351

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion Apps/APN-UIKit/APN UIKit/Util/DeepLinksHandlerUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ extension AppDeepLinksHandlerUtil {
userInfo: userInfo
)
}
return true
// navigation to browser depends if we handle the url inside app or not
return doesMatchUniversalLink(url)
}

/// Check if a provided URL matches a predefined universal link that app supports..
/// - Parameter url: The URL to be checked.
/// - Returns: A boolean indicating whether the provided URL matches the universal link.
func doesMatchUniversalLink(_ url: URL) -> Bool {
let universalLink = URL(string: "http://applinks:ciosample.page.link/spm")

return (url.scheme == "http" || url.scheme == "https") &&
url.host == universalLink?.host &&
url.path == universalLink?.path
}
}
7 changes: 6 additions & 1 deletion Sources/MessagingInApp/MessagingInAppImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal class MessagingInAppImplementation: MessagingInAppInstance {
private var profileStore: ProfileStore

private var eventListener: InAppEventListener?
private let threadUtil: ThreadUtil

init(diGraph: DIGraph) {
self.siteId = diGraph.sdkConfig.siteId
Expand All @@ -21,6 +22,7 @@ internal class MessagingInAppImplementation: MessagingInAppInstance {
self.jsonAdapter = diGraph.jsonAdapter
self.inAppProvider = diGraph.inAppProvider
self.profileStore = diGraph.profileStore
self.threadUtil = diGraph.threadUtil
}

func initialize() {
Expand Down Expand Up @@ -68,7 +70,10 @@ extension MessagingInAppImplementation: ScreenTrackingHook {
public func screenViewed(name: String) {
logger.debug("setting route for in-app to \(name)")

inAppProvider.setRoute(name)
// Gist expects webview to be launched in main thread and changing route will trigger locally stored in-app messages for that route.
threadUtil.runMain {
self.inAppProvider.setRoute(name)
}
}
}

Expand Down