Huawei HMS initialize without Json file

507 views Asked by At

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

2

There are 2 answers

0
zhangxaochen On BEST ANSWER

Update:

  • Push Kit

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.

0
Nithin On

If your trying to implement HiAI through DevEco you can run application without agconnect-services.json file. To know more use the link.

In another way you can try Coding Assistant, it will do automatic Environment Configuration for some kits. Currently it will support Push Kit and there is no need to download agconnect-services.json manually. To know more use the link