Show prompt for HMS Core upgrade

781 views Asked by At

I used getIapClient(Context context) in my app for object instantiation. The app could not work well with devices with older versions of HMS core.

How to make the app show a prompt for HMS core upgrade?

2

There are 2 answers

1
Zinna On BEST ANSWER

Please use activity:

getIapClient(Activity activity)

instead of context when calling this method.

More details on Huawei developer site

2
zhangxaochen On
  1. Please use public static IapClient getIapClient(Activity activity)

As @Zinna said, the getIapClient(Activity activity) method is recommended for your app to obtain an IapClient instance. When the input parameter is not of the Activity type, if the HMS Core (APK) version is earlier than that requested for calling the APIs of IAP, the IAP SDK returns only the error code 907135003 and cannot display the upgrade wizard page.

If you call relevant APIs through an activity, the HMS Core SDK will automatically install or update HMS Core (APK), and you do not need to take any other actions. Please refer to the docs here.

  1. Please add the following metadata to the application block in AndroidManifest.xml: (to prompt a user to install or update HMS Core (APK) when the user uses your app on a device where HMS Core (APK) is not installed or is in an unsupported version)
<application ...>
    <meta-data     
       android:name="com.huawei.hms.client.channel.androidMarket"  
       android:value="false" />
    ...
</application>

About Configuring Metadata, please refer to the docs.