Search code examples
flutterdartin-app-purchasein-app-subscriptionrevenuecat

Revenue Cat: How to manage two different API keys in one Flutter app?


After connecting Revenue Cat with my app on Google Play Store and Apple AppStore I now have two different API keys. One for Google and one for Apple. But when I want to set the API key inside my Flutter app I have to provide only one single API key like this:

  static Future init() async {
    await Purchases.setup('myApiKey');
  }

I can't find anything about it in the documentation and I don't know if I have to use one single API key in my Flutter app or if I should simply use a platform check like this:

  static const _apiKeyGoogle = 'googleApi';
  static const _apiKeyApple = 'appleApi';

  static Future init() async {
    if (Platform.isAndroid) {
      await Purchases.setup(_apiKeyGoogle);
    } else {
      await Purchases.setup(_apiKeyApple);
    }
  }

Does anybody know how to do that? I appreciate every answer.


Solution

  • The second option with the variables in a constants file.