-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathBridgeJsJava.js
47 lines (43 loc) · 1.08 KB
/
BridgeJsJava.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class WebViewBridgeJs2Java
{
static IsInWebView()
{
return navigator.userAgent.includes('wv');
}
static SendMobileNumber(mobileNumber)
{
let mobJsonStr = JSON.stringify({ name:"mobileNumber", value: mobileNumber });
this.SendData(mobJsonStr);
}
static SendButtonEventAutoBook(bButtonState)
{
let jsonStr = JSON.stringify({ name:"buttonEventAutoBook", value: bButtonState });
this.SendData(jsonStr);
}
static SendWindowUrl() {
let jsonStr = JSON.stringify({ name:"stored_url", value: window.location.href });
this.SendData(jsonStr);
}
static SendData(jsonStr)
{
try {
if (WebViewBridgeJs2Java.IsInWebView()) {
JavaScriptInterface.jsToAndroid(jsonStr);
}
}
catch (e)
{
return;
}
}
}
function androidToJs(obj)
{
console.log("androidToJs", obj);
objJson = JSON.parse(obj);
let bearerToken = objJson["token"];
if (bearerToken != undefined)
{
LogInUser(LogInUser);
}
}