ALBRECHT Active Member Licensed User Aug 3, 2019 #1 Hello, I would know if i am in the good way or if exists a better more simple process I have an app that use SMS permissions (but not needs PHONE permission) To suggest to the user the + Phone code (before the phone numbers) : +33 682000012 in relation to the Device Country code : Code: Copy Dim r As Reflector r.Target = r.RunStaticMethod("java.util.Locale", "getDefault", Null, Null) Log(r.RunMethod("getCountry")) So, i have create a db table "CountryCodePhone" with all Codes : Country Codes + Phones Codes 273 records like that ( from E.123 : Notation for national and international telephone numbers ): there : https://en.wikipedia.org/wiki/List_of_country_calling_codes 30: GR / 31: NL / 32: BE / 33: FR / 34: ES / 350: GI / 351: PT / 352: LU / 353: IE / 354: IS / 355: AL ... as b4x always reserves me good surprises, is there a better way (without asking the entire permission of the Phone, to see the phone code of the device) Regards Michel
Hello, I would know if i am in the good way or if exists a better more simple process I have an app that use SMS permissions (but not needs PHONE permission) To suggest to the user the + Phone code (before the phone numbers) : +33 682000012 in relation to the Device Country code : Code: Copy Dim r As Reflector r.Target = r.RunStaticMethod("java.util.Locale", "getDefault", Null, Null) Log(r.RunMethod("getCountry")) So, i have create a db table "CountryCodePhone" with all Codes : Country Codes + Phones Codes 273 records like that ( from E.123 : Notation for national and international telephone numbers ): there : https://en.wikipedia.org/wiki/List_of_country_calling_codes 30: GR / 31: NL / 32: BE / 33: FR / 34: ES / 350: GI / 351: PT / 352: LU / 353: IE / 354: IS / 355: AL ... as b4x always reserves me good surprises, is there a better way (without asking the entire permission of the Phone, to see the phone code of the device) Regards Michel
E emexes Expert Licensed User Longtime User Aug 3, 2019 #2 ALBRECHT said: as b4x always reserves me good surprises Click to expand... Same for me too! is there a better way (without asking the entire permission of the Phone, to see the phone code of the device) Click to expand... I'm sure there will be a better way, but a roundabout backup Plan B might be to use the current location data, do a reverse lookup to get the address: https://www.b4x.com/android/forum/t...-navigation-on-google-map.108193/#post-676428 TBH I thought that the telephone code would be included in the returned data, but given that phone numbers nowadays aren't as tied to geography as they used to be... fair enough. Upvote 0
ALBRECHT said: as b4x always reserves me good surprises Click to expand... Same for me too! is there a better way (without asking the entire permission of the Phone, to see the phone code of the device) Click to expand... I'm sure there will be a better way, but a roundabout backup Plan B might be to use the current location data, do a reverse lookup to get the address: https://www.b4x.com/android/forum/t...-navigation-on-google-map.108193/#post-676428 TBH I thought that the telephone code would be included in the returned data, but given that phone numbers nowadays aren't as tied to geography as they used to be... fair enough.
ALBRECHT Active Member Licensed User Aug 3, 2019 #3 yes exactly, that's why I think that the standardization table E.123 (to be updated according to the evolutions of the countries) seems to me, to be a more precise solution? except that some countries have duplicate codes, for example : Russia, i suggest the 5 : RU +79: UK RU +78: UK RU +74: UK RU +73: UK RU +7: UK Kazakhstan, i suggest the 3 : KZ +77: KZ KZ +76: KZ KZ +7: KZ Michel Upvote 0
yes exactly, that's why I think that the standardization table E.123 (to be updated according to the evolutions of the countries) seems to me, to be a more precise solution? except that some countries have duplicate codes, for example : Russia, i suggest the 5 : RU +79: UK RU +78: UK RU +74: UK RU +73: UK RU +7: UK Kazakhstan, i suggest the 3 : KZ +77: KZ KZ +76: KZ KZ +7: KZ Michel
E emexes Expert Licensed User Longtime User Aug 3, 2019 #4 ALBRECHT said: except that some countries have duplicate codes Click to expand... Hmm. That might actually be fixable by my next outside-the-box no-phone-permission-needed idea... use IP reverse-geocode service, eg: https://www.iplocation.net/ although that service doesn't have country telephone code, but if we can find one that does, then it will likely decode it down to the region country code that is serviced by your user's mobile service provider. On a related note, my mobile phone used to default to a location 1000 km away, which I assumed was because that other city was the headquarters and thus nominal location for my phone's service provider. But I tried iplocation.net on that phone just now, and it's got me to under 14 km: the location it returns is the city centre, and I'm out in a suburb of that city. Upvote 0
ALBRECHT said: except that some countries have duplicate codes Click to expand... Hmm. That might actually be fixable by my next outside-the-box no-phone-permission-needed idea... use IP reverse-geocode service, eg: https://www.iplocation.net/ although that service doesn't have country telephone code, but if we can find one that does, then it will likely decode it down to the region country code that is serviced by your user's mobile service provider. On a related note, my mobile phone used to default to a location 1000 km away, which I assumed was because that other city was the headquarters and thus nominal location for my phone's service provider. But I tried iplocation.net on that phone just now, and it's got me to under 14 km: the location it returns is the city centre, and I'm out in a suburb of that city.
E emexes Expert Licensed User Longtime User Aug 3, 2019 #5 emexes said: but if we can find one that does, then it will likely decode it down to the region country code that is serviced by your user's mobile service provider. Click to expand... Ask not, and ye shall receive anyway!!! I don't know if this works as well everywhere as it does here, but check this out: https://www.ip2location.com/ which returns accurate* information for me like: including not just the telephone country code, but the telephone area code as well (03 = Victoria and Tasmania). And the weather station (see next post). * seems to be based on nominal location of mobile phone service provider, thus 14 km from my actual location, but... still good enough to freak people out. The postcode looked a bit strange, since Victoria postcodes are usually 3000..3999 but I know there are some special cases and so I checked and yep, 8010 is the postcode for... hang on, that's Optus, not Vodafone... let me double-check this on my mobile... ... ... is all good, same info, except for ISP. Upvote 0
emexes said: but if we can find one that does, then it will likely decode it down to the region country code that is serviced by your user's mobile service provider. Click to expand... Ask not, and ye shall receive anyway!!! I don't know if this works as well everywhere as it does here, but check this out: https://www.ip2location.com/ which returns accurate* information for me like: including not just the telephone country code, but the telephone area code as well (03 = Victoria and Tasmania). And the weather station (see next post). * seems to be based on nominal location of mobile phone service provider, thus 14 km from my actual location, but... still good enough to freak people out. The postcode looked a bit strange, since Victoria postcodes are usually 3000..3999 but I know there are some special cases and so I checked and yep, 8010 is the postcode for... hang on, that's Optus, not Vodafone... let me double-check this on my mobile... ... ... is all good, same info, except for ISP.
E emexes Expert Licensed User Longtime User Aug 3, 2019 #6 Also returns Weather Station = Melbourne (ASXX0075), so if you call up: https://weather.com/en-AU/weather/today/l/ASXX0075 then magically appears: although JSON would be useful for direct import, I guess. Last edited: Aug 3, 2019 Upvote 0
Also returns Weather Station = Melbourne (ASXX0075), so if you call up: https://weather.com/en-AU/weather/today/l/ASXX0075 then magically appears: although JSON would be useful for direct import, I guess.
E emexes Expert Licensed User Longtime User Aug 3, 2019 #7 This: https://www.ipfingerprints.com/ has pinned me down to within 4 km in adjoining suburb (not sure about state code = 07 = Queensland, though). This: https://tools.keycdn.com/geo has pinned me down to under 1 km and in correct suburb. I think I'm going to stop now - this is getting a bit too close for my liking. ps this: http://extreme-ip-lookup.com/json/ provides data in JSON (not telephone country code, but presumably similar is achievable with other sites) pps like this: https://ipapi.co/json or even https://ip-api.io/json which provides link to this: Bonza! Last edited: Aug 3, 2019 Upvote 0
This: https://www.ipfingerprints.com/ has pinned me down to within 4 km in adjoining suburb (not sure about state code = 07 = Queensland, though). This: https://tools.keycdn.com/geo has pinned me down to under 1 km and in correct suburb. I think I'm going to stop now - this is getting a bit too close for my liking. ps this: http://extreme-ip-lookup.com/json/ provides data in JSON (not telephone country code, but presumably similar is achievable with other sites) pps like this: https://ipapi.co/json or even https://ip-api.io/json which provides link to this: Bonza!