简体   繁体   English

React Native Firebase Analytics 获取用户国家

[英]React Native Firebase Analytics get User Country

Problem问题

I want to get the user's current country in React Native to find out if they're in the EU so I can display a GDPR consent form to collect personal data for advertising purposes.我想在 React Native 中获取用户当前所在的国家/地区,以了解他们是否在欧盟,这样我就可以显示 GDPR 同意表来收集用于广告目的的个人数据。

I don't want to have to ask the user to allow location services as my app doesn't need to have their current location.我不想要求用户允许位置服务,因为我的应用不需要拥有他们当前的位置。

I have React Native Firebase installed in my app and I noticed that Analytics will tell me the users country in my console.我在我的应用程序中安装了 React Native Firebase,我注意到 Analytics 会在我的控制台中告诉我用户所在的国家/地区。

Does anyone know how I can access the user's country via React Native Firebase Analytics in my JS code?有谁知道我如何通过我的 JS 代码中的 React Native Firebase Analytics 访问用户的国家/地区?

If anyone has a better way to get the user's country I'm open to that as well!如果有人有更好的方法来获取用户所在的国家/地区,我也对此持开放态度!

Thanks in advance!提前致谢!

Google Analytics for Firebase automatically derives the location of the user from a number of data points, mostly from the IP address from which they connect. Google Analytics for Firebase 自动从许多数据点中获取用户的位置,主要来自他们连接的 IP 地址。 There is no API to get that information from Analytics.没有 API 可以从 Analytics 获取该信息。

Most applications that need this information use a similar IP-to-location lookup API to determine it, or inspect the phone settings for the user.大多数需要此信息的应用程序使用类似的 IP 到位置查找 API 来确定它,或检查用户的电话设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM