2

I have an android app , that i need to deploy for both Google play and App gallery

and it contains Ads and IAP , the problem is that

1- What is the correct way to handle the ads/purchase ?

 if hmsAvailable() {
    // use Huawei ads/iap 
 } else {
    // use Google ads/iap
 } 

2- I need the same code base ,so Would it cause a problem to have both GMS and HMS inside Gradle.build ?

3- It seems that Huawei is about to prevent GMS installation on it's devices , so if a user has paid the premium IAP with a google account , would this means he can't restore it when GMS is blocked on Huawei ?

sheko
  • 516
  • 4
  • 15

3 Answers3

1

I don't hear anything about blocking GMS by Huawei, but hear about blocking apps on google play if they have Huawei SDKs.

So, you should choose this way:

Create different flavors for different stores and include huawei/google libraries only for huawei/google flavor.

And yes, to restore iaps on different devices with different stores you have to store purchases info on your own server, not rely on response from store.

mohax
  • 4,435
  • 2
  • 38
  • 85
  • Hi @mohax thanks for the feedback , can i go with payment without having a user system ? meaning will the store tell me whether the user has paid it or not for a restore in both google and huawei ? plus is it an acceptable UX ? also when i add a user system for the app does this mean when a user buys the app in ios and login in android i have to make it un locked also ? thanks in advance – sheko Apr 20 '22 at 23:55
  • Can you help with this https://stackoverflow.com/questions/72591101/add-keywords-to-huawei-app-in-huawei-develoer-console – sheko Jun 12 '22 at 13:15
1

1- What is the correct way to handle the ads/purchase ?

You can make a judgment, but it is recommended that Google Play and App Gallery integrate their own Ads and IAP SDKs, and include Huawei and Google libraries.

2- I need the same code base ,so Would it cause a problem to have both GMS and HMS inside Gradle.build ?

On Google Play, only apps integrated with the Google IAP can be released. If the apps integrated with the HMS, the apps cannot be released.

There are no restrictions on Huawei App Gallery.

3- It seems that Huawei is about to prevent GMS installation on it's devices , so if a user has paid the premium IAP with a google account , would this means he can't restore it when GMS is blocked on Huawei ?

It is not that Huawei prevents the installation of the GMS, but that the GMS cannot be installed on Huawei devices.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • Hi @shirley thanks for the feedback , can i go with payment without having a user system ? meaning will the store tell me whether the user has paid it or not for a restore in both google and huawei ? plus is it an acceptable UX ? also when i add a user system for the app does this mean when a user buys the app in ios and login in android i have to make it un locked also ? thanks in advance – sheko Apr 20 '22 at 23:55
  • If there is no user system, the interworking between Google Play and AppGallery cannot be implemented. If the user has paid it in the AppGallery, the Google Play cannot be perceived. Similarly, if the user has paid it in the Google Play, the Google Play cannot be perceived in the AppGallery. – zhangxaochen Apr 21 '22 at 02:26
  • As for your second question, it depends on whether the application supports data interworking between different servers. You have the control right. It is not related to the HMS or GMS. We are only responsible for returning the payment result. – zhangxaochen Apr 21 '22 at 02:30
  • last question can i use this library https://github.com/mrmans0n/smart-location-lib to git user location on huawei or i have to use huawei' location kit ? – sheko Apr 21 '22 at 13:43
  • @sheko It is better to use Huawei's library. If there is any problem during the integration of Huawei's Location Kit, you can [ask another question](https://stackoverflow.com/questions/ask) for us check. – zhangxaochen Apr 22 '22 at 02:13
  • can you help with this https://stackoverflow.com/questions/72591101/add-keywords-to-huawei-app-in-huawei-develoer-console – sheko Jun 12 '22 at 13:15
1
  1. You can define product flavors or check for GMS/HMS availability inside the code itself. GMS+HMS Product Flavors https://stackoverflow.com/a/61839463/14880637

    gms { dimension "services" buildConfigField "String", "SERVICE_USED", '"g"'

     }
     hms {
         dimension "services"
         buildConfigField "String", "SERVICE_USED", '"h"'
     }
    

GMS/HMS Availability Check https://stackoverflow.com/a/60587678/14880637

public static boolean isHmsAvailable(Context context) {
    boolean isAvailable = false;
    if (null != context) {
        int result = HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(context);
        isAvailable = (com.huawei.hms.api.ConnectionResult.SUCCESS == result);
    }
    Log.i(TAG, "isHmsAvailable: " + isAvailable);
    return isAvailable;
}

public static boolean isGmsAvailable(Context context) {
    boolean isAvailable = false;
    if (null != context) {
        int result = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
        isAvailable = (com.google.android.gms.common.ConnectionResult.SUCCESS == result);
    }
    Log.i(TAG, "isGmsAvailable: " + isAvailable);
    return isAvailable;
}
  1. There is no issue with having both GMS and HMS in the gradle. ChoiceSDk is a good example which in use by published apps. https://www.hihonor.com/global/club/topicdetail/choice-sdk-gms-to-hms-apps-for-huawei-appgallery/topicId-69134/ You can see that ChoiceSDk requires both GMS and HMS configuration in the gradle. https://github.com/bluesource/ChoiceSDK

  2. Huawei is not blocking GMS on their devices. Google has blocked GMS access to Huawei phones released after May 2019. https://www.pocket-lint.com/phones/news/huawei/148102-what-does-huawei-s-google-ban-mean-for-your-huawei-or-honor-phone. Because GMS is not available on Huawei phones released after May 2019, it will not be possible to access Google IAP from those devices. It's recommended that you store purchase history on your own server to ensure that users will still be able to access their premium purchase.

Zinna
  • 1,947
  • 2
  • 5
  • 20
  • Hi @zinna thanks for the feedback , can i go with payment without having a user system ? meaning will the store tell me whether the user has paid it or not for a restore in both google and huawei ? plus is it an acceptable UX ? also when i add a user system for the app does this mean when a user buys the app in ios and login in android i have to make it un locked also ? thanks in advance – sheko Apr 20 '22 at 23:56
  • Can you help with this https://stackoverflow.com/questions/72591101/add-keywords-to-huawei-app-in-huawei-develoer-console – sheko Jun 12 '22 at 13:15