Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Huawei HMS initialize without Json file

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

like image 310
Mahdi-Malv Avatar asked Oct 06 '20 11:10

Mahdi-Malv


People also ask

How to integrate Huawei Mobile Services (HMS)?

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.

Where can I download Huawei agconnect JSON file?

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.

Which apps and services does HMS core support?

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.

How to connect AppGallery to Huawei Developer Console?

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.


1 Answers

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.

  • Map Kit:

MapsInitializer.setApiKey("Your API Key");

  • Site Kit:

SearchService searchService = SearchServiceFactory.create(this, "API key");

  • ML Kit:

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.

like image 69
shirley Avatar answered Nov 09 '22 07:11

shirley