1

有没有办法检测用户是否是:

  1. 能够切换到另一台设备/该区域有一个可以接受切换的蓝牙设备
  2. 如果用户单击他们的切换浏览器按钮以加载传递的页面

我们有一个应用内网页视图,并将用户所在的网址从移动设备转移到桌面。我们只想记录它是否能够切换,以及用户在切换时是否选择了链接。

这是我的代码:

    func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
        webView.userActivity = nil
        if let handoffUrl = webView.url, webView.userActivity == nil && webView.url?.scheme != nil && UIApplication.shared.canOpenURL(handoffUrl) {
            webView.userActivity = NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb)
            webView.userActivity?.isEligibleForHandoff = true
            print("//HERE handing off a website - this gets hit even if a user has no devices to handoff to: ", handoffUrl)
            webView.userActivity?.webpageURL = handoffUrl
        }
        webView.userActivity?.becomeCurrent()
    }
    
4

0 回答 0