收入分类:如何在一个Flutter应用程序中管理两个不同的API密钥



在Google Play Store和Apple AppStore上将Revenue Cat与我的应用程序连接后,我现在有两个不同的API密钥。一个给谷歌,一个给苹果。但是当我想在我的Flutter应用程序中设置API密钥时,我只需要提供一个像这样的API密钥:

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

我在文档中找不到任何关于它的信息,我也不知道我是否必须在Flutter应用程序中使用一个API密钥,或者我是否应该简单地使用这样的平台检查:

static const _apiKeyGoogle = 'googleApi';
static const _apiKeyApple = 'appleApi';
static Future init() async {
if (Platform.isAndroid) {
await Purchases.setup(_apiKeyGoogle);
} else {
await Purchases.setup(_apiKeyApple);
}
}

有人知道怎么做吗?我感谢每一个答案。

常量文件中的变量的第二个选项。

最新更新