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
Now you can register Handlers using the APT tech.Follow the steps:
10
+
11
+
1. add the jitpack dependencies as below ;
12
+
2. add the annotation `@EasyBridgeHandler` to your handler;
13
+
3. A class Named `EBHandlerManager` will be generated after buiding the project;
14
+
4. call the static method `EBHandlerManager#register(webview)` when you init the webview for the activity/fragment.
15
+
16
+
#### ✔️ Using Java IN JavaScript
17
+
18
+
EasyBridge allow you to invoke Java function both in **Synchronize** and **Asynchronous** ways.(But it's pity that the Asynchronous way is only opened for you nowadays)
19
+
20
+
Follow the steps:
21
+
22
+
1. Register the document event `WebViewJavascriptBridgeReady` in your JavaScript logic;
23
+
2. Using the `easyBridge#callHandler(handlerName, args, callback)`in your JavaScript when you received the event that the bridge had been injected.The object named `easyBridge`can be renamed as you like.
24
+
25
+
#### ✔️ Using JavaScript IN Java
26
+
27
+
You can call all the JavaScirpt function that had been registed to the `easyBridge`.Steps as follow:
28
+
29
+
1. Register the document event `WebViewJavascriptBridgeReady` in your JavaScript logic;
30
+
2. Using the `easyBridge#registerHandler(handlerName, handler)`to registed all the functions that you want to be invoked in Java;
31
+
3. Calling the function `EasyBridgeWebView#callHandler(handlerName,parameters,resultCallBack)` in Java layer to reach your JavaScript functions.
32
+
33
+
#### ✔️ Global Security Policy Check
34
+
35
+
Global Security check will be actived once you had defined it before in the situations below:
36
+
37
+
- Time at bridge Injecting in Java layer
38
+
39
+
no bridge object will be injected if breaking the rule of global security check.The old bridge object injected in the previous page also will be removed .
40
+
41
+
42
+
- Time at calling the Java functions in JavaScript layer
43
+
44
+
No Java functions will be invoked if breaking the rule of global security check.
45
+
46
+
#### ✔️ Security policy check on Handlers
47
+
48
+
The last point to make a security check based on the security policy of the handler that is about to be invoked in JavaScript.
49
+
50
+
You can set your policy according to the current page's url and the parameters you received from JavaScript
51
+
52
+
# DEPENDENCIES
53
+
54
+
**EasyBridge** had been pubished to [Jitpack](https://jitpack.io/#easilycoder/EasyBridge), add the dependencies to your project before using it,follow the steps:
55
+
56
+
1. add the Jitpack responsitory
57
+
58
+
```gradle
59
+
allprojects {
60
+
repositories {
61
+
...
62
+
maven { url 'https://jitpack.io' }
63
+
}
64
+
}
65
+
```
66
+
67
+
2. add the core dependencies of EasyBridge
68
+
69
+
```gralde
70
+
dependencies {
71
+
compile 'com.github.easilycoder.EasyBridge:easybridge:0.0.1'// change the version to the newest one
72
+
}
73
+
```
74
+
75
+
3. If you would to try to APT tech for registing handler ,add the dependencies below
76
+
77
+
```gradle
78
+
dependencies {
79
+
compile 'com.github.easilycoder.EasyBridge:easybridge-annotation:0.0.1' // change the version to the newest one
80
+
annotationProcessor 'com.github.easilycoder.EasyBridge:easybridge-processor:0.0.1' // change the version to the newest one
0 commit comments