I want to access javascript file store properties. How can I do that?
I want to fetch user ID. and also I want to call a function which will set push token to server. any suggestion? for example:
func getProfileUserIDFromJavaScript() {
let javascript = "GameState.Profile.Uid()"
webView.evaluateJavaScript(javascript) { (result, error) in
if let uID = result as? String {
// Use the adUnitId obtained from JavaScript
print("User ID: \(uID)")
self.userID = uID
} else {
print("Error obtaining User ID: \(error?.localizedDescription ?? "Unknown error")")
}
}
}
Call function with """ function """ Solved my problem.
I searched this on many websites but finally I found this which works well for me.