android - 我已经构建了一个 react native 应用程序。我在迪拜地区限制此应用程序

标签 android ios react-native

我正在构建一个 react native 应用程序。该应用程序在迪拜的使用受到限制。

通过分别更改 iOS 和 Android 的应用商店和 Google Play 控制台中的设置,可以限制该应用在某些国家/地区的使用。以防万一,用户在新加坡下载该应用程序,然后搬到迪拜。他还能访问该应用程序吗?如果是,我该如何防止这种情况?

如果用户在某个国家/地区下载应用程序,然后转移到受限制的国家/地区,则他应该无法访问该应用程序。

最佳答案

Install & import axios from npm

使用国家/地区名称和国家/地区代码初始化您的组件状态

constructor(props) {
    super(props);
    this.state = {
        countryName: '',
        countryCode: ''
    }
}

将此函数添加到您的组件

getGeoInfo = () => {
    axios.get('https://ipapi.co/json/').then((response) => {
        let data = response.data;
        this.setState({
            countryName: data.country_name,
            countryCode: data.country_calling_code
        });
    }).catch((error) => {
        console.log(error);
    });
};

并调用 this.getGeoInfo() 将国家/地区名称和国家/地区代码设置为您所在的州。我从 componentDidMount() 调用它

componentDidMount(){
    this.getGeoInfo();
}

检查国家迪拜并在此处屏蔽

关于android - 我已经构建了一个 react native 应用程序。我在迪拜地区限制此应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57848604/

相关文章:

ios - 在 Parse 后端保存 Stripe customerId

android - 已编译的 apk 正在尝试访问 metor 服务器 react native

ios - Swift 3,成功传递数据但var在使用时返回nil

reactjs - 抽屉导航器 : Change Background Color

android - react native java.security.cert.CertPathValidatorException : Trust anchor for certification path not found

android - 如何使用 KSOAP 故障消息

android - ActionBar 菜单项无法使用支持库

android - Robotium 主页按钮并恢复到应用程序

android - 在图库中保存图像

ios - NSInvalidArgumentException 使用 UISegmentedControl