-1

I am building an app that requires the functionality of reading SMS from the inbox. It's a kind of app that Microsoft built known as SMS organizer. I'm trying to build it for the local crowd and I'm using react-native to do the same. I read many libraries but none seem to be helpful or informative for my cause.

Anyone has any idea for how I can accomplish the same. PS- I'm aiming to do it for both androids as well as ios.

Abhay
  • 117
  • 9
  • You definitely can't do it for iOS. Apps are not allowed to read messages as it would be a privacy violation. – Paulw11 Feb 16 '21 at 19:12
  • @Paulw11 What if, I declare it before asking for permissions from the user. In our app, the first thing is the declaration stating the SMS permission for usage by the app. – Abhay Feb 17 '21 at 04:48
  • In iOS there is no permission to request. You cannot ask for access to SMS messages. There is no way the user can give you permission. – Paulw11 Feb 17 '21 at 09:03

1 Answers1

0

True- We cannot read sms in IOS devices.

For Android, I found a library that helps to achieve this.

import SmsAndroid from 'react-native-get-sms-android'; 

var filter = {
  box: 'inbox',
};

const Readsms_list = async () => {
  SmsAndroid.list(
    JSON.stringify(filter),
    (fail) => {
      console.log('Failed with this error: ' + fail);
    },
    (count, smsList) => {
      console.log('Count: ', count);
      console.log('List: ', smsList);
      var arr = JSON.parse(smsList);

      arr.forEach(function (object) {
    // 'Object: ' +
    console.log(object);
    // console.log('-->' + object.date);
    // console.log('-->' + object.body);
  });
},

); };

This helps in reading all the SMS from the device.

Abhay
  • 117
  • 9