IPhone emergency programming

I want to make a button with which a user can dial an emergency number.

There seems to be no specific method to call, so I think I need to use

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]]; 

and assign a phone number yourself. Nevertheless, although I know that it is 911 in the USA, 999 in England, etc. I'm not sure how to determine which country the user is in. I can get their locale, but if they install their language manually or travel outside their country, that would be unreliable. I can decide their location, but this will not work if they have disabled GPS or do not have an internet connection.

I heard that 112 is now the universal standard for GSM phones - will it work on all iPhones?

+4
source share
2 answers

I'm not sure how to get different numbers, but suppose you have a set of them (say, a country dictionary), then you can use the network information about which country the phone is currently in.

You can do this using the CoreTelephony structure, in particular the CTTelephonyNetworkInfo and CTCarrier . Here is a small sample that will receive the ISO 3166-1 country code of the current carrier.

 CTTelephonyNetworkInfo *network = [[[CTTelephonyNetworkInfo alloc] init] autorelease]; CTCarrier *carrier = [network subscriberCellularProvider]; NSString *countryCode = [carrier isoCountryCode]; 

Now countryCode will have a code (as far as I know, the Alpha-2 code), unique for each country, here is a list of these

+8
source

It seems that there is no specific method to call, so I think I should use

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: PhoneNumber]];

It is right.

As for the dial number, I don’t think there is a global emergency number.

0
source

Source: https://habr.com/ru/post/1412273/


All Articles