Downloading the AAR Packages and JSON File
o Sign in to HUAWEI Developer and download the AAR packages required.
o AAR packages related to HMS Push kit is displayed as below
Figure 1-1 Downloading AAR packages
Table 1-1 Links to the AAR packages
Configure app information in App Gallery Connect by referring to Figure 1-2 and ensure that the required services are enabled. Refer below link for the steps. https://developer.huawei.com/consumer/en/codelab/HMSPreparation/index.html#0
Figure 1-2 Configuring app information in App Gallery Connect
Open AAR packages with rar tool and rename the class.jar and AndroidManifest.xml files. (It is recommended that the two files be renamed consistently with the AAR package names.)
Figure 1-3 Renaming files
B4A will automatically incorporate files in the assets folder of an AAR package to the assets folder of your main project.
- Encapsulating Java Files Using SLC
Configure the Java project.
SLC wraps Java project and adds it to the B4A library. For demonstration purposes, we have created a Java project.
It is recommended that you name the first folder b4x in src. Otherwise, the library generated with SLC may not function properly.
Figure 1-8 Java project
Import the following two lines of code to each Java file
Modify the context.
B4A does not recognize the Context class. Therefore, when parsing a class that contains the @Version(1.0f) annotation, it will report an error if a method of the class has referenced Context. In this case, you need to change Context to the B4A object BA
Figure 1-11 Context example
The following describes the @Events annotation.
This annotation is used to report specific events in the Java method to the listener registered on B4A.
The code on B4A is also required to implement this function. Take the **getPushToken** method in **PushWork** as an example. If you want to pass the push token in the Java method to a listener on B4A, do as follows:
The value of NewToken in the red box must be the same as xxxx of Listener_xxxx in the listening event name added to B4A in the previous step.
The value of #AdditionalJar is the name of the AAR package (with a file name extension) in the Addition folder