Skip to content

How to build application for Huawei with mobile messaging plugin

Davor Komušanac edited this page Dec 5, 2022 · 1 revision

We don't have support for Huawei in MobileMessaging plugin yet, however on a separate branch - huawei_wrapper we've demonstrated which changes need to be done on the plugin wrapper code and how to setup everything in Example app to build it for Huawei platform.

You can check the diff between master branch (6.3.4 version) and huawei_wrapper branch

Changes which need to be performed:

1. Install local version of the plugin

  1. Checkout branch locally
  2. Make a local plugin version by calling npm pack from folder where you checked out the branch
  3. Install local version of the plugin npm install <path to the .tgz file>

Notice: All changes on the current branch are done for the 6.3.4 plugin version, if you are using other version, you may try to apply changes yourself on the version you need, by checking changes on huawei_wrapper branch.

2. Check the Example and apply changes to your app accordingly

  1. Provide HMS App ID to the android/app/src/res/values/strings.xml. It could be taken from Huawei Developer Console - Application settings
    <resources>
        ...
        <string name="app_id">HMS App ID</string>
    </resources>
    
  2. Download file agconnect-services.json from App Gallery Connect and copy it to the android/app folder
  3. Provide signing configs as it done in Example app
  4. Setup application at Infobip portal for Huawei platform, if you haven't done it already.
  5. Apply 'com.huawei.agconnect' plugin instead of 'com.google.gms.google-services' in android/app/build.gradle - link to the Example
- apply plugin: 'com.google.gms.google-services'
+ apply plugin: 'com.huawei.agconnect'
  1. In the android/build.gradle add maven { url 'https://developer.huawei.com/repo/' } for repositories inside buildscript and allprojects
buildscript {    
    repositories {
        ...
+       maven { url 'https://developer.huawei.com/repo/' }
    }
...
}
allprojects {
    repositories {
        ...
+       maven { url 'https://developer.huawei.com/repo/' }
    }
}
  1. In the android/build.gradle remove classpath for Google Messaging Services Plugin - classpath 'com.google.gms:google-services' and add classpath for App Gallery Connect classpath 'com.huawei.agconnect:agcp:1.6.0.300' - link to the Example
- classpath 'com.google.gms:google-services:4.3.10'
+ classpath 'com.huawei.agconnect:agcp:1.6.0.300'

Notice: Would be not worse to make cleanups ./gradlew clean, npm run --clear-cache, if you are oprning project in Android studio you can make File->Invalidate Caches

Clone this wiki locally