{"id":13773149,"url":"https://github.com/adorsys/sms-parser-android","last_synced_at":"2025-04-16T00:31:54.862Z","repository":{"id":50310107,"uuid":"87316743","full_name":"adorsys/sms-parser-android","owner":"adorsys","description":"Intercept a sms in your application","archived":false,"fork":false,"pushed_at":"2020-02-10T10:19:40.000Z","size":227,"stargazers_count":97,"open_issues_count":2,"forks_count":25,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-05-02T06:19:27.610Z","etag":null,"topics":["android","library","sms","sms-message","sms-parser"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adorsys.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":"2017-04-05T14:06:58.000Z","updated_at":"2024-03-29T04:33:37.000Z","dependencies_parsed_at":"2022-09-07T23:30:14.565Z","dependency_job_id":null,"html_url":"https://github.com/adorsys/sms-parser-android","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adorsys%2Fsms-parser-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adorsys%2Fsms-parser-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adorsys%2Fsms-parser-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adorsys%2Fsms-parser-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adorsys","download_url":"https://codeload.github.com/adorsys/sms-parser-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223691241,"owners_count":17186771,"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":["android","library","sms","sms-message","sms-parser"],"created_at":"2024-08-03T17:01:12.037Z","updated_at":"2024-11-08T13:27:28.279Z","avatar_url":"https://github.com/adorsys.png","language":"Kotlin","funding_links":[],"categories":["Android"],"sub_categories":[],"readme":"# SMS Parser - Android\n\n## Receiving and Parsing SMS Messages on Android Devices\n\n[![Build Status](https://travis-ci.org/adorsys/sms-parser-android.svg?branch=master)](https://travis-ci.org/adorsys/sms-parser-android)\n[![Download](https://api.bintray.com/packages/andev/adorsys/smsparser/images/download.svg)](https://bintray.com/andev/adorsys/smsparser/_latestVersion)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-SMS%20Parser%20Android-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5652)\n[![API](https://img.shields.io/badge/API-14%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=14)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) \n[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/)\n\n### Introduction\n\nThis module was created for getting specific codes out of incoming SMS messages.\nTo use it you create a Config object where you specify the ___BEGIN___ and ___END___ message phrases \u0026 the ___SMS sender numbers___ from which you want to read the sms content.\nThe received code then can be used according to your need (activation, authentication etc...).\n\n### How it Works\n\nIf you get a SMS message like this:\n\n```\nThis is an automated message used by X-App. You can delete this message at any time.\nBEGIN-MESSAGE\n08ff08d3b2981eb6c611a385ffa4f865\nEND-MESSAGE\n```\nand the sender of the message is one of the numbers you have specified in your Config object the parsing process will begin.\n\nFirst the module reads the whole message.\nIt then checks if it contains the ___BEGIN___ and ___END___ phrases you specified.\nIf it does then it takes only the part that is between those phrases and send a broadcast to you app with the specific code and the sender phone number.\nIn this case the module would send a broadcast containing `08ff08d3b2981eb6c611a385ffa4f865` and the sender number.\n\nFor more info read ___Usage___.\n\n### Usage\n\nAdd the module to your apps build.gradle:\n\n```golang\ncompile 'de.adorsys.android:smsparser:0.0.3'\n```\n\nFirst of all you have to create a Config object to configure the modules use:\n```java\n        SmsConfig.INSTANCE.initializeSmsConfig(\n                \"BEGIN-MESSAGE\",\n                \"END-MESSAGE\",\n                \"0900123456\", \"0900654321\", \"0900900900\");\n```\nHere the two parameters are the keywords that will be used for the code to be extracted from the sms message.\nThe ___third___ parameter is a varargs (...) parameter, where you can give a series of phone numbers (as Strings), which will be checked against for reading sms content.\n\nThen before startinganything you have to aks for the SMS Permmision on Android 6.0 and higher, or else the module won't work:\n```java\n        if (Build.VERSION.SDK_INT \u003e= Build.VERSION_CODES.M) {\n            SmsTool.requestSMSPermission(Context);\n        }\n```\n\nThen you need to create a LocalBroadcastManager and BroadcastReceiver, like this:\n```java\n    @NonNull\n    private LocalBroadcastManager localBroadcastManager;\n\n    private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {\n        @Override\n        public void onReceive(Context context, Intent intent) {\n            if (intent.getAction().equals(SmsReceiver.INTENT_ACTION_SMS)) {\n                String receivedSender = intent.getStringExtra(SmsReceiver.KEY_SMS_SENDER);\n                String receivedMessage = intent.getStringExtra(SmsReceiver.KEY_SMS_MESSAGE);\n                smsSenderTextView.setText(getString(R.string.text_sms_sender_number,\n                        receivedSender != null ? receivedSender : \"NO NUMBER\"));\n                smsMessageTextView.setText(getString(R.string.text_sms_message,\n                        receivedMessage != null ? receivedMessage : \"NO MESSAGE\"));\n            }\n        }\n    };\n```\n\nLocalBroadcastManager is used instead of standard BroadcastManager for security reasons, so no other app can listen to the broadcasts that are sent.\n\nYou must create register and unregister methods for the BroadcastReceiver and call them in onResume() and onPause(), respectively:\n```java\n    @Override\n    protected void onResume() {\n        registerReceiver();\n        super.onResume();\n    }\n    \n    @Override\n    protected void onPause() {\n        unRegisterReceiver();\n        super.onPause();\n    }\n\n    private void registerReceiver() {\n        localBroadcastManager = LocalBroadcastManager.getInstance(Context);\n        IntentFilter intentFilter = new IntentFilter();\n        intentFilter.addAction(SmsReceiver.INTENT_ACTION_SMS);\n        localBroadcastManager.registerReceiver(broadcastReceiver, intentFilter);\n    }\n\n    private void unRegisterReceiver() {\n        localBroadcastManager.unregisterReceiver(broadcastReceiver);\n    }\n```\n\n\n\n### Contributors:\n[@drilonreqica](https://github.com/drilonreqica)\n\n[@itsmortoncornelius](https://github.com/itsmortoncornelius)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadorsys%2Fsms-parser-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadorsys%2Fsms-parser-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadorsys%2Fsms-parser-android/lists"}