我正在构建一个 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/