流星 - 检测 Sim Phone 号

Meteor - Detect Sim Phone Number

有没有办法在使用 Meteor 时检测移动设备上的 SIM phone 号码? 此外,使用 phone 号码登录用户(例如在 Whatsapp 或 Viber 中)的正确行为和预防措施是什么?

提前致谢。

目前无法通过网站或网络应用程序从使用移动设备的访问者那里获取 phone 号码。

我估计这不太可能实现。想象一下,如果访问您 phone 上的网站允许网站所有者未经许可获取您的手机号码?

原生应用和混合应用不同,因为它们 运行 设备上,允许它们访问该设备的 api 和硬件。

但是只是因为native/hybrid应用程序可以访问phone number,它不是那么简单,看看 this SO question 和关于违反 ios 条款和条件的答案,并让应用程序因使用该功能而被应用程序商店拒绝。

所以你的问题的答案是不,你现在不能这样做,而且很可能永远不会。

这取决于它是 Web 应用程序还是混合应用程序

第一种情况,网络应用

如果您谈论的是 Web 上的 Meteor 应用程序,您将使用 phone 的浏览器访问它,那么答案是 (请参阅 atmd的回答)

第二种情况,混合应用

如果您谈论的是使用 Cordova 构建的混合应用程序,即 meteor run android,那么 YES 是可能的

如果你想走得更快,我编写了一个示例 Meteor 应用程序: https://github.com/Erdou/meteor-cordova-phonenumber-example

1。添加 Android 平台(如果尚未完成)

$ meteor add-platform android   

2。为 Cordova

添加 phone 数字插件

没有适用于 Meteor 的插件,因此您需要手动安装。我们将在这里使用这个: https://github.com/rotorgames/phonegap-telephonenumber-plugin

  • 获取 .git 路径(在 Github 的 克隆 按钮附近):https://github.com/rotorgames/phonegap-telephonenumber-plugin.git
  • 获取最新的提交哈希。在Github中点击Latest commit号,这个号会完整显示:ca0f55481fe8ea61e7857e96c1324591596271ee
  • 命令将是:$ meteor add cordova:[a plugin name]@[.git path]#[commit hash]

在我们的例子中:

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

3。在您的应用中使用它

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。 运行 混合应用程序

$ meteor run android

应该有用! :)

最后一个案例作为建议

正如atmd所说,不推荐使用这个功能。如果您想知道用户的 phone 号码,最好的方法是实现您猜到的 Viber 或 WhatsApp 使用的经典短信发送/确认。

我没有测试它,但甚至有一个 Meteor 包可以做到: https://github.com/DispatchMe/meteor-accounts-sms