Search code examples
androidhuawei-mobile-serviceshuawei-push-notification

Supporting Huawei IAP for multiple build types


Following the Huawei official docs I was able to integrate IAP into our app. I am able to query product details and perform a subscription, so the integration is working fine for the release build. However, we have multiple build types, imagine: com.app, com.app.beta, com.app.debug

To support multiple build flavours I did the required changes as adviced per docs here. This however, it's not enough to have IAP on beta builds for example. Any interaction with Huawei SDK on beta build results in: CERT_FINGERPRINT_ERROR = 6003, which makes sense, because the SHA256 registered in the Huawei console is the one for the release certificate, not the one for the beta certificate.

The question I have is how to register a new pair of com.app.debug/SHA256 for beta certificate so I can test IAP also on other build types?

Now, I know, this can be avoided by signing the beta build with the release certificate, like this:

buildTypes {
    beta {
       signingConfg.release   // <---- use release config 
 
       // .....
    }
}

but this is more like a workaround than solution. Ideally we should be able to regiter a new app with a new fingerprint. How this can be done?


Solution

    1. If you use the same package name but different signatures in the debug, beta, and release environments, configure all the signatures in AppGallery Connect. same package
    2. If you use different package names and signatures in the debug, beta, and release environments, you actually have three apps.

    In this case, you need to create the apps in AppGallery Connect and configure corresponding signatures. Add Apps

    When creating an app, you can select a project that contains apps in other environments to facilitate unified management. creating an app1 creating an app2

    You can view and modify the configurations of different apps in the same project, as shown in the figure below. same project