How do I get the user's country iOS / Android

Get help using Construct 2

Post » Wed Aug 12, 2015 9:42 am

Hey !

Is it possible to get the user's country ? My app has a social integration (facebook) but it seems to not be possible anymore to get the user's country from Facebook :/
So my question is : how do I get the user's country on iOS (important) / Android (less important)

I know it's possible to get the language from the Browser object but as some countries use the same language it will not be accurate and I want it to be accurate :/
Thanks in advance !!
B
7
S
1
Posts: 58
Reputation: 683

Post » Wed Aug 12, 2015 1:19 pm

Okay so I found a solution (two to be exact) :

First solution: FB Graph API call /me?fields=location{location} will return :
"location": {
"location": {
"city": "Ottawa",
"country": "Canada",
"latitude": 45.4167,
"longitude": -75.7,
"state": "ON",
"zip": "<<not-applicable>>"
},

Then you just have to get result["location"]["location"]["country"]

Second solution is to get the user's locale if location is not defined, this will return something like :
fr_FR, the FR = the country code
B
7
S
1
Posts: 58
Reputation: 683


Return to How do I....?

Who is online

Users browsing this forum: charliesan763 and 17 guests