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

  • 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 !!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)