-2

Is there a way to detect the SIM phone number on a mobile device while using Meteor? Moreover, what is the correct behavior to have and precautions to make to log users using their phone number (like in Whatsapp or Viber for example)?

Thank you in advance.

user229044
  • 232,980
  • 40
  • 330
  • 338
zahikaram
  • 173
  • 1
  • 9
  • unless they enter it, no, it's not possible, and quite right too – atmd Aug 21 '15 at 12:18
  • Actually in native applications, this is allowed. I don't really what the -1 was for: I did research everything and found nothing... and if it really does not make any sense, then why did they provide an API for it in native calls? – zahikaram Aug 21 '15 at 12:21
  • I did'nt downvote you, but you are talking to different things, a native application is running on the device and as such has guidelines and security restrictions. Being able to get the number form a website/web app would be a big security/spamming risk. – atmd Aug 21 '15 at 12:23
  • I am sorry but even hybrid frameworks such as PhoneGap allow such functionality (here's an example: https://github.com/macdonst/TelephoneNumberPlugin). Since Meteor uses PhoneGap I don't really see why such functionality for you completely does not make any sense. – zahikaram Aug 21 '15 at 12:28
  • I think you are confused. phonegap still runs on the device, are you talking about builind a hybrid app using phonegap and metoer as your backend? non of that is mentioned in your questions so obviously different context will give different answers – atmd Aug 21 '15 at 12:31
  • You should clarify (if true) that you are using Cordova/Phonegap and you want the API for that, this will remove a lot of the downvotes and the question closing FUD. – Andrew Mao Aug 21 '15 at 20:58
  • I've edited to clarify it (peer review waiting). But I should say that your second question (about phone number logging) is too vague. It implies using SMS etc. You are not asking a clear technical question. – Erdal G. Nov 11 '15 at 07:21

2 Answers2

3

Getting the phone number from a visitor using a mobile device via a website or webapp is currently not possible.

I'd guesstimate that it very unlikly to ever be possible. Imagine if visiting websites on your phone allowed site owners to get your mobile number without permission??

Native and hybrid apps are different because they run on the device, allowing them access to the api's and hardware of that device.

But just because native/hybrid apps can access the phone number, it's not that simple, take a look at this SO question and the answer concerning breaking ios t&c and having the app rejected from the app store for using that functionality.

So the answer to your question is No, you can't do that right now, and very likley not ever.

Community
  • 1
  • 1
atmd
  • 7,430
  • 2
  • 33
  • 64
3

It depends if it's a web app or a hybrid application

First case, web app

If you're talking about a Meteor application on the web which you will access with your phone's browser, then the answer is NO (see atmd's answer)

Second case, hybrid app

If you're talking about a hybrid app built with Cordova i.e. meteor run android, then YES it's possible

If you want to go quicker, I coded an example Meteor app: https://github.com/Erdou/meteor-cordova-phonenumber-example

1. Add Android platform (if not done yet)

$ meteor add-platform android   

2. Add a phone number plugin for Cordova

There is no plugin ready for Meteor, so you need to it manually. We will use this one here: https://github.com/rotorgames/phonegap-telephonenumber-plugin

  • Get the .git path (near Github's Clone button): https://github.com/rotorgames/phonegap-telephonenumber-plugin.git
  • Get the latest commit hash. In Github, click on the Latest commit number, and this number will fully show: ca0f55481fe8ea61e7857e96c1324591596271ee
  • The command will be: $ meteor add cordova:[a plugin name]@[.git path]#[commit hash]

In our case:

$ meteor add cordova:cordova-plugin-phonenumber@https://github.com/rotorgames/phonegap-telephonenumber-plugin.git#ca0f55481fe8ea61e7857e96c1324591596271ee

3. Use it in your app

if (Meteor.isCordova) {
    TelephoneNumber.get(function(result) {
        console.log('Phone number: ' + result.line1Number);
      }, function() {
        console.log('Error. Do the phone have this feature? (Settings > About Phone > SIM > Number)');
      });
  }

4. Run the hybrid app

$ meteor run android

It should work! :)

A final case as a suggestion

As atmd said, using this feature is not recommended. If you want to know user's phone number, the best will be the implement the classical SMS sending / confirmation used by Viber or WhatsApp as you kind of guessed it.

I didn't test it, but there is even a Meteor package for that: https://github.com/DispatchMe/meteor-accounts-sms

Erdal G.
  • 2,694
  • 2
  • 27
  • 37
  • This answer was unexpectedly perfect for a somewhat vague question. – Zargoon Dec 27 '16 at 06:52
  • 1
    @Zargoon Thanks! Truth is that he got lucky: 1) I was exactly solving the guy's problem at that time 2) I was warming up with my first SO answers :) – Erdal G. Dec 27 '16 at 13:01