Signing Up With Mobile

Joined
Oct 18, 2011
Messages
160
Reaction score
0
Points
16
Hi,

I am in the process of building a new app. The app allows users to signup with their mobile number (including the country prefix), which they then verify with a SMS.

When the user has signed up, the app checks the users contacts in their phonebook to see which of their contacts is already signed up and using the app too. It then adds each of these contact to a Friends list.

I have a big problem which i can't seem to get my head around:

Most mobile numbers start with a 0 when they are used within their own country, such as 087 123 4567 for Ireland... however each country also has their own country prefix, such as +353 for Ireland, and when we use the prefix code, we usually drop the 0, such as +353 87 123 4567

As i mentioned above, the app uses the mobile number as your unique identifier and checks to see which of your friends are already using the app. Some users will have their friends saved as 087 333 4444 and others will have them saved with the country prefix +353 87 333 4444 and therefore the app will not recognise the simple version of 087 333 4444

Can anyone think of a way of resolving this? Thanks in advance for your help.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Moved to the development forum.

The solution is here is rather simple - simply read the first character of the phone number string, check to see if it's a zero and then do something accordingly. If it isn't, they likely have the country code at the front.

I'm not sure what language you're using here but effectively, you want something that lets you get a slice of a string.
 
OP
O
Joined
Oct 18, 2011
Messages
160
Reaction score
0
Points
16
Hey, thanks for your reply.

Sometimes users save the +353 as 00353 too, so the proposal above wouldn't work.

Any other ideas?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
You'll need to code a conditional that accounts for all possibilities. As far as I can tell, there's no way around that unless you read only the last seven digits or so and use that as a unique identifier. This would get around having to deal with the beginning part of the string. That would give you ten million possible unique combinations (0000000 - 9999999). Granted, that wouldn't account for area/country codes though. However, you could run a check against the DB if one of those seven digit codes matched another and then assign a different number based on that (or have a second column for area/country code).
 
OP
O
Joined
Oct 18, 2011
Messages
160
Reaction score
0
Points
16
Thanks Vansmith, i have thought of this, however i don't think that will work either as a mobile number in the US could have the last 7 digits the same as a mobile in Ireland.

US: 1 (555) 555 5555
Ireland: 087 555 5555
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Hence the second column for country code. ;)

So, if the seven digit numbers are the same, consult the second column with the country code. Your psuedocode would look something like:
Code:
variable number = get results from phone column
variable countrycode = get result from country code column
if number == what the user input then
     check to see if number exists elsewhere in the column
     if it doesn't then
          ...do what you need to do...
     if it does exist elsewhere then
          get the country code input by the user
          check country code against the country codes in the rows with number
          if the countrycode == what the user input && the number == what the user input then
               ...do what you need to do...

It's not the most elegant psuedocode but it should do the job of explaining what it is that I'm trying to explain.
 
OP
O
Joined
Oct 18, 2011
Messages
160
Reaction score
0
Points
16
Ha, yes i get you but problem is that we are relying on how users are saving their friend's phone numbers in their actual phonebook, some will not have a country code prefix and others will :)

I wonder would using the last 8 digits be safe (maybe not)
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Ha, yes i get you but problem is that we are relying on how users are saving their friend's phone numbers in their actual phonebook, some will not have a country code prefix and others will :)
You can't account for all user choices. ;)

I wonder would using the last 8 digits be safe (maybe not)
Maybe but you're still going to run into an issue where the beginning of the phone number string will differ.

One thing to note as well is the existence of shared country codes. For example, North American countries all have the same country code (1). It might help reading this.
 
OP
O
Joined
Oct 18, 2011
Messages
160
Reaction score
0
Points
16
Yeah, i know Whatsapp are able handle this so they must use some clever method.

All of the options i can think of don't cover all choices.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top