Is it possible to initialize HMS without a agconnect-services.json
and provide the keys at runtime?
Using a similar service (Fcm) we can initialize an app:
val builder = FirebaseOptions.Builder()
.setApiKey(apiKey)
.setGcmSenderId(senderId)
.setProjectId(project)
.setApplicationId(appId)
FirebaseApp.initializeApp(context, builder.build())
Therefore, you can use it without need of a json
file to be parsed.
Is there a similar solution for this using HMS
and AppGallery
?
BTW, I'm trying to implement PushKit
Integrating Huawei Mobile Services (HMS) is a prerequisite for using all the kits Huawei is offering in your application. 1. Create an App in AppGallery Connect 1.1 - Sign In/Register to Huawei Developer website and click to Console 1.2 - Click to the AppGallery Connect button in order to access AppGallery connect.
After finishing all the steps above, “agconnect-services.json” file needs to be downloaded from developer.huawei.com and this downloaded json file needs to be moved to the under “app” folder of your project.
Huawei-developed apps (such as HUAWEI Health) and certain apps or games downloaded from HUAWEI AppGallery or cloned from a Huawei phone have integrated with Huawei ecosystem capabilities and require support from the basic services provided by HMS Core, such as HUAWEI ID, game, and health services.
1.1 - Sign In/Register to Huawei Developer website and click to Console 1.2 - Click to the AppGallery Connect button in order to access AppGallery connect. 1.3.1 - Click My projects button to create new project or add new app to existing your projects.
Update:
You can add the following code in your manifest file:
<meta-data
android:name="com.huawei.hms.client.appid"
<!-- Replace value xxx with the actual appid.-->
android:value="appid=xxx">
</meta-data>
Currently, HMS does not provide a unified solution for code-based initialization. However, some kits support code-based initialization.
MapsInitializer.setApiKey("Your API Key");
SearchService searchService = SearchServiceFactory.create(this, "API key");
MLApplication.getInstance().setApiKey("your ApiKey");
If you use only these kits, you do not need to integrate the JSON file. Instead, you can complete code-based initialization through the API key.
We will analyze and discuss your requirement for a unified code-based initialization solution and reply to you as soon as possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With