You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// The chat may have links within that are targeted at opening in a new window. The ``HubspotChatView`` triggers these using the SwiftUI open url environment action. By default, this will cause the system to open the url in the external browser.
34
+
///
35
+
/// These can be handled in an alternative way if desired by providing an alternative url handler using SwiftUIs exsting open url environment feature
36
+
///
37
+
/// ```swift
38
+
/// HubspotChatView()
39
+
/// .environment(\.openURL, OpenURLAction(handler: { URL in
40
+
/// /// Handle opening of link in chat in some in app browser, or some other method
41
+
/// return OpenURLAction.Result.systemAction
42
+
/// }))
43
+
/// ```
44
+
///
31
45
/// ### Opening Chat From Push Notification
32
46
///
33
47
/// If opening chat view in response to a push notification , ideally extract important information from the notification using the ``PushNotificationChatData`` struct , and pass to the initialiser like so:
// Most navigations are allowed, as that matches default behaviour. But for links specifically, we do additional checks
376
+
switch navigationAction.navigationType {
377
+
case.linkActivated:
378
+
if navigationAction.targetFrame?.isMainFrame ??false{
379
+
// For links specifically targeting the main frame, lets assume that's intentional to replace chat?
380
+
// If links are incorrectly being sent targeting the main frame handle it like the else branch for all link activated
381
+
return.allow
382
+
}elseiflet url = navigationAction.request.url {
383
+
// A link not targeting the main frame would be a pop up, other tab type attempt at opening. Use the system open URL and cancel any nav within the webview
384
+
urlHandler(url)
385
+
return.cancel
386
+
}else{
387
+
// Not sure what the link type would be without a url - whatever it is , just default to allowing it
0 commit comments