ios - best guess at phone number with country code - ios

I'm trying to retrieve contacts phone numbers to be able to send SMS on behalf of a user. When the number includes the country code (ie starts with +, or 00) I'm fine. However when this is not the case, I'm trying to guess what the country code should be.
// contact is a CNContact with at least one phone number
contact.phoneNumbers[0].value.value(forKey: "countryCode") as? String
returns a country code like us or fr (even if it's not recommended to do so) but I've found it to sometime be inaccurate. My guess is that Apple uses the user's local. It even misclassify numbers with explicit country code. For instance a number 00 54 ... is classified as us while it's from Argentina.
I can also use the user's current local (NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as? String) and use that to fill missing country codes. But it will obviously misclassify some numbers.
Is there's a better less error prone way?

Related

CXCallDirectoryPhoneNumber not support 0 at beginning

CXCallDirectoryPhoneNumber not support 0 at beginning
eg.
Add 0 in front of the number becomes 8-binary number,
But my phone number has 0 in front of it.
If my phone number is 010-12345678,
8612345678 is not matched,
8601012345678 is not matched,
01012345678 is not matched.
Some tips for someone who might still struggle on this... In short, if you number is 010-12345678, then 8612345678 should be the choice. Formats like "+8612345678" as a string worked for me too.
Just ran into the similar issue, and found out the reason why Call Directory extension sometimes "does not work" is simply not because of your phone number format. iOS will actually cache your phone numbers which are set when the extension is ran previously, i.e. it will not update your blocking or the identification phone numbers each time you change your source code and restart you app extension as you expected.
One way to invalidate the iOS cache is to toggle your app's option in Settings -> Phone -> Call Blocking & Identification (and maybe restart your app as well).

How do you I register for Electronic Data Interchange (EDI) ISA number?

I will receive 850 purchase order. In return, I need to generate and send 997 response, which include ISA/GS number. Where and who do I register with for this ISA id?
Thanks in advance
EDI systems are typically limited in scope to be between a few or even just 2 different organizations. These organizations need to decide beforehand on how much of the full EDI specification they're going to use, and how they're going to specify IDs. See here.
Also, see here. From this it looks like DUNS numbers or variants on them are common choices for IDs.
So your organization and the others need to just figure out if you're going to use DUNS number or ad-hoc made up numbers or what.
Your 850 will have an ISA (interchange) and GS (group) identifier where you will be designated as the receiver. When you generate the 997, the IDs will be reversed so that you are the sender of the acknowledgement.
Back in the day, it was important to uniquely identify yourself. X12 handles this via a qualifier/ID pair. Let's say you want to use your phone number. Your ID would be 12 (qualifier) and then 5555551212 (your ID / phone number). You could make up something arbitrary like ZZ (qualifier: mutally defined) and ACMEWIDGETSCO. Again, it should be something unique and not already found on a VAN. This is probably less probable these days than it was 10 years ago when everyone was using VANs predominantly.
Look at the below example. The IDs in this example are made up, but could be DUNS, HIN, Industry identifier, phone number, mutually defined, etc. Just for frame of reference, I used SENDER and RECEIVER.
ISA*00* *00* *ZZ*SENDER *ZZ*RECEIVER *150622*2131*U*00401*000000006*0*T*>~
GS*PO*SENDER*RECEIVER*20150622*2131*4*X*004010~
In other words, you don't need to register it with anyone, you just need to make sure it is unique on the networks you are trading on with - that's really the important part. If you're using direct connections (AS2, FTP) to your partners, it won't matter as much, but the best practice is to give your company an ID that is somewhat unique (DUNS, phone numbers, arbitrary name). If you don't understand EDI, download EDI Notepad from Liaison and that should give you a better picture of how the data is described.

sqlite query for range search having text for ios app

I have a table with columns as LowerFrequency, HigherFrequency and ID. The frequencies entered have a suffix of khz or mhz. I want to search a specific frequency by checking the range it falls in i.e between the lower and higher frequencies and fetch the respective ID.
The query I implemented was as below but it returns a wrong output:
select tablename.ID where "100 khz" between tablename.LowerFrequency and tablename.HigherFrequency;
I know the reason is because of the khz that follows the integer. But I need some suggestions to handle this as I am not in a situation of changing the whole DB file because it is time consuming.
I will be integrating this DB with my iPhone app. So any solutions in Objective C would also be appreciated. I mean some kind of conversion.

Phone Number Detection Issues

In my BB app, i want to detect phone numbers as well as to call those phone numbers. In order to do that i have used ActiveRichTextField instead of LabelField. This field works fine to detect the phone numbers but the problem i am getting is that it fails to detect some of the numbers especially of the country Australia. It detects phone numbers of India perfectly fine but not for Australia and some other numbers. What i have done for this is posted below as:
ActiveRichTextField descField;
if (isFocaseble) {
descField = new ActiveRichTextField(replacedString.trim(),
ActiveRichTextField.FIELD_LEFT |
ActiveRichTextField.USE_ALL_WIDTH |
ActiveRichTextField.FOCUSABLE)
i have checked here if its focused or not because only numbers have to be gained focused since there are other data also which have no need to be given focus and replacedString is what the data getting from the webservice.Below are the snaps of my screen through which one can get the clear idea of my problem.
(1) Below are Numbers of Australia:
(2) Numbers of Australia
(3) Numbers of India
Can anybody have any idea regarding this? why i am not able to detect whole numbers and where am i lacking?
Any sort of help would be appreciable.

Get MSISDN number through code

Is there any way to get MSISDN(Mobile Subscriber Integrated Services Digital Network-Number) number through code.
I have navigated to other questions as well but none of them are answered.
Any help towards the path will really be appreciated.
Note: I require MSISDN number(number uniquely identifying a subscription in a GSM) and not iPhone's UDID. Purpose is to fetch the voicemails for that MSISDN
Additional Information : I just found out that MSISDN number is the combination of your country code and your Phone number.
MSISDN = CC + NPA + SN
CC - Country Code
NPA - Number Planning Area
SN - Phone Number
Sorry, but you cannot retrieve the users MSISDN with public methods in the iOS SDK (I'm not sure about private methods). I'd be very surprised if Apple ever sanctioned this.
You used to be able to get the number with
[[NSUserDefaults standardUserDefaults] objectForKey:#"SBFormattedPhoneNumber"]
but I think that was removed in iOS 4.0.

Resources