首页 > 解决方案 > 在 Ionic 3 for IOS 中读取 SMS

问题描述

我们有一个 Ionic 应用程序,我们需要在其中读取带有验证码的 SMS,用户在注册应用程序时将收到该验证码。

我们正在使用这个在Android中完美运行的插件。但似乎不适用于IOS
我也看过这个Native 插件,但我认为它不支持阅读短信。

这就是我们阅读短信的方式:

...
declare let SMS: any;

readListSMS() {
  let filter = {
    box: 'inbox',            // 'inbox' (default), 'sent', 'draft'
    address: '<phone-number>',
    indexFrom: 0,            // start from index 0
    maxCount: 1,             // count of SMS to return each time
    read: 0
  };
  if (SMS) {
    SMS.listSMS(filter,
      (smss) => {
        // Here we have access to those sms
      },
      error => {
        alert('error list sms: ' + error);
      }
    );
  }
}
...

问题是在为 ios 构建应用程序时它不会读取短信,实际上它甚至没有进入回调。

从我读过的内容来看,这不可能,互联网上也没有太多关于这个主题的信息!

我的问题是:

标签: ioscordovatypescriptionic3sms

解决方案


推荐阅读