Closed makma closed 3 years ago
@makma Yep, its documentation issue
This is happen because the fingerprintjs
object undefined, as well as vendorId
string must be escaped
Here is right solution:
let vendorId = UIDevice.current.identifierForVendor.flatMap { "'\($0.uuidString)'" } ?? "undefined"
WKUserScript(source: "window.fingerprintjs = { 'vendorId' : \(vendorId) }",
injectionTime: .atDocumentStart,
forMainFrameOnly: false)
@spalt08
can you please suggest better solution for script source and keypath?
And also maybe fingerprintjs
object should be avoided as unnecessary?
Yep, @spalt08 has already written to me, I've checked this solution and it really works, gonna update readme with full swiftUI example in a minute, thx
Whem I follow the guidelines for the webview approach, vendorId tag is not reflected.
Steps to reproduce:
struct ContentView: View { var body: some View { Webview(url: URL(string: "https://eager-hermann-4ea017.netlify.app")!) } }
struct Webview: UIViewRepresentable { let url: URL
}
Actual output:
Note: I've also tried to set window object after
webview.load(request)
Questions and suggestions:
window.fingerprintjs.vendorId
orwindow.FingerprintJS.vendorId
?