{"id":4600,"url":"https://github.com/msmakhlouf/react-native-android-sms","last_synced_at":"2025-06-22T23:07:49.996Z","repository":{"id":57335284,"uuid":"48477315","full_name":"msmakhlouf/react-native-android-sms","owner":"msmakhlouf","description":"A react native android module to list/send sms.","archived":false,"fork":false,"pushed_at":"2019-04-16T06:55:46.000Z","size":33,"stargazers_count":61,"open_issues_count":7,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-22T17:59:09.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msmakhlouf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-23T07:49:53.000Z","updated_at":"2024-11-02T04:40:44.000Z","dependencies_parsed_at":"2022-08-24T21:41:08.154Z","dependency_job_id":null,"html_url":"https://github.com/msmakhlouf/react-native-android-sms","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/msmakhlouf/react-native-android-sms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmakhlouf%2Freact-native-android-sms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmakhlouf%2Freact-native-android-sms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmakhlouf%2Freact-native-android-sms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmakhlouf%2Freact-native-android-sms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msmakhlouf","download_url":"https://codeload.github.com/msmakhlouf/react-native-android-sms/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmakhlouf%2Freact-native-android-sms/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261380911,"owners_count":23149966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:17:17.542Z","updated_at":"2025-06-22T23:07:44.983Z","avatar_url":"https://github.com/msmakhlouf.png","language":"Java","funding_links":[],"categories":["Components"],"sub_categories":["System"],"readme":"# Sms for react-native android\n\nA react native android module to list/send sms.\n\n[![npm](https://img.shields.io/npm/v/react-native-android-sms.svg?style=flat-square)](https://www.npmjs.com/package/react-native-android-sms)\n\n[![GitHub tag](https://img.shields.io/github/tag/msmakhlouf/react-native-android-sms.svg?style=flat-square)](https://github.com/msmakhlouf/react-native-android-sms)\n\n## Setup\n\nThere are five steps in the setup process.\n\n1. Install the module via npm.\n2. Update `android/settings.gradle` file.\n3. Update `android/app/build.gradle` file.\n4. Register the module in `MainActivity.java` file. \n5. Rebuild and restart package manager\n\n* Install the module via npm\n```bash\n npm i --save react-native-android-sms\n```\n\n* Update `android/settings.gradle` file\n\n```gradle\n...\ninclude ':react-native-android-sms'\nproject(':react-native-android-sms').projectDir = new File(settingsDir, '../node_modules/react-native-android-sms')\n```\n\n* Update `android/app/build.gradle` file\n\n```gradle\n...\ndependencies {\n    ...\n    compile project(':react-native-android-sms')\n}\n```\n\n* Register the module (in `MainActivity.java` file)\n\n```java\nimport my.qash.react.SmsPackage;  // \u003c--First, we import import\n\npublic class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {\n\n  ......\n  private static Activity mActivity = null;\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    mReactRootView = new ReactRootView(this);\n\n    mActivity = this;\n    mReactInstanceManager = ReactInstanceManager.builder()\n      .setApplication(getApplication())\n      .setBundleAssetName(\"index.android.bundle\")\n      .setJSMainModuleName(\"index.android\")\n      .addPackage(new MainReactPackage())\n      .addPackage(new SmsPackage(this))      // \u003c------- Then, we add the package\n      .setUseDeveloperSupport(BuildConfig.DEBUG)\n      .setInitialLifecycleState(LifecycleState.RESUMED)\n      .build();\n\n     mReactRootView.startReactApplication(mReactInstanceManager, \"MyExampleApp\", null);\n\n    setContentView(mReactRootView);\n  }\n\n  ......\n\n}\n```\n* Run `react-native run-android` from your project root directory\n\n\n\n\n## Usage\n\n- List all SMS messages matching filters.\n\n```js\nvar SmsAndroid = require('react-native-android-sms');\n\n/* List SMS messages matching the filter */\nvar filter = {\n    box: 'inbox', // 'inbox' (default), 'sent', 'draft', 'outbox', 'failed', 'queued', and '' for all\n    // the next 4 filters should NOT be used together, they are OR-ed so pick one\n    read: 0, // 0 for unread SMS, 1 for SMS already read\n    _id: 1234, // specify the msg id\n    address: '+97433------', // sender's phone number\n    body: 'Hello', // content to match\n    // the next 2 filters can be used for pagination\n    indexFrom: 0, // start from index 0\n    maxCount: 10, // count of SMS to return each time\n};\n\nSmsAndroid.list(JSON.stringify(filter), (fail) =\u003e {\n        console.log(\"OH Snap: \" + fail)\n    },\n    (count, smsList) =\u003e {\n        console.log('Count: ', count);\n        console.log('List: ', smsList);\n        var arr = JSON.parse(smsList);\n        for (var i = 0; i \u003c arr.length; i++) {\n            var obj = arr[i];\n            console.log(\"Index: \" + i);\n            console.log(\"--\u003e\" + obj.date);\n            console.log(\"--\u003e\" + obj.body);\n        }\n    });\n\n/* \nEach sms will be represents by a JSON object represented below\n\n{\n  \"_id\": 1234,\n  \"thread_id\": 3,\n  \"address\": \"2900\",\n  \"person\": -1,\n  \"date\": 1365053816196,\n  \"date_sent\": 0,\n  \"protocol\": 0,\n  \"read\": 1,\n  \"status\": -1,\n  \"type\": 1,\n  \"body\": \"Hello There, I am an SMS\",\n  \"service_center\": \"+60162999922\",\n  \"locked\": 0,\n  \"error_code\": -1,\n  \"sub_id\": -1,\n  \"seen\": 1,\n  \"deletable\": 0,\n  \"sim_slot\": 0,\n  \"hidden\": 0,\n  \"app_id\": 0,\n  \"msg_id\": 0,\n  \"reserved\": 0,\n  \"pri\": 0,\n  \"teleservice_id\": 0,\n  \"svc_cmd\": 0,\n  \"roam_pending\": 0,\n  \"spam_report\": 0,\n  \"secret_mode\": 0,\n  \"safe_message\": 0,\n  \"favorite\": 0\n}\n\n*/\n\n\n```\n\n- Send an SMS\n\n```js\nvar SmsAndroid = require('react-native-android-sms');\nvar text = \"Hello ... QASH I AM YOUR FATHER !!!!!\";\nvar addressList = {\n    addressList: [\n        \"+97433------\", \"+97434------\"\n    ]\n}\n\nSmsAndroid.send(JSON.stringify(addressList), text, (fail) =\u003e {\n        console.log(\"OH Snap: \" + fail)\n    },\n    (status) =\u003e {\n        console.log('Status: ', status);\n    });\n\n```\n\n- Delete an SMS (coming soon)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsmakhlouf%2Freact-native-android-sms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsmakhlouf%2Freact-native-android-sms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsmakhlouf%2Freact-native-android-sms/lists"}