3

I am developing a mobile app with react native.

The app is ready and finished for the iOS and Android platforms. However, I have to implement new functionalities in order to make my App working on Huawei devices (whose use HMS).

I am currently implementing @hmscore/react-native-hms-push. The plugin works correctly on Huawei devices, however, on Android devices, such as Samsung, it causes me the following problem: when I start my App on the Samsung, a prompt appears telling me the HMS Services are not installed and it asks if I want to install them or not (Yes/No).

I would like this prompt to never appear on non-Huawei devices. The user should never see this prompt and continue to use FCM Push.

In fact, if HMS Services are installed on Samsung, I have problems managing different Push Tokens and other logics.

How can I prevent the @hmscore plugin from showing this prompt when starting the App?

shogitai
  • 1,823
  • 1
  • 23
  • 50

2 Answers2

3

On AndoridManifest.xml (library level, @hmscore/react-native-hms-push) you will find the following code fragment:

   <application>
       <service android:name="com.huawei.hms.rn.push.services.MessagingHeadlessService" />
       <service
               android:name="com.huawei.hms.rn.push.remote.HmsPushMessageService"
               android:exported="false">
           <intent-filter>
               <action android:name="com.huawei.push.action.MESSAGING_EVENT" />
           </intent-filter>
       </service>
       <meta-data
               android:name="push_kit_auto_init_enabled"
               android:value="true" />
   </application>

Changing this:

 <meta-data
                android:name="push_kit_auto_init_enabled"
                android:value="true" />

to this:

 <meta-data
                android:name="push_kit_auto_init_enabled"
                android:value="false" />

the prompt disappears. However, it is a change made at the library level (inside node_modules). According to what is described in manifest merge(Android Developer) it is possible to override this property in the AndroidManifest.xml (main level).

The final fix is with this code snippet put into AndroidManifest.xml (main level):

        <meta-data
                tools:replace="android:value"
                android:name="push_kit_auto_init_enabled"
                android:value="false" />

Hope this helps you to prevent the prompt appearing at App startup.

speak94
  • 66
  • 5
1

The reason that showing this prompt was because you called the HMS interface on the GMS mobile phone. You can use the HMS service on the GMS mobile phone.And when the GMS on the mobile phone is unavailable, you can download the HMS Core to make the service available.

Please kindly refer to this: How to check Google Mobile Services enable in device or not?

Huawei has provided some HMS Core kit plugins for React native:

Reference documents

Push Kit plugins for React Native

Huawei Availability React Native Plugin provides capability of HMS Core APK detection on android devices. If there is not, the plugin provides navigation to AppGallery for HMS Core installation.

For Details, You can follow the Docs.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108