Giter Site home page Giter Site logo

stfalcon-studio / smsverifycatcher Goto Github PK

View Code? Open in Web Editor NEW
845.0 37.0 183.0 130 KB

Android library for phone number verification feature in your app. Automatically copies verification code from SMS right into the app. Made by Stfalcon

Home Page: https://stfalcon.com

Java 100.00%
android sms verification catcher confirmation

smsverifycatcher's Introduction

SmsVerifyCatcher

codebeat badge

alt tag

A library for implementing interception of SMS with a verification code using a few lines of code.

Who we are

Need iOS and Android apps, MVP development or prototyping? Contact us via [email protected]. We develop software since 2009, and we're known experts in this field. Check out our portfolio and see more libraries from stfalcon-studio.

Download

  1. Add jitpack to the root build.gradle file of your project at the end of repositories.
allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
  1. Add the dependency
dependencies {
  ...
  implementation 'com.github.stfalcon-studio:SmsVerifyCatcher:[last_version]'
}  

Usage

Add permissions to AndroidManifest.xml:

  <uses-permission android:name="android.permission.RECEIVE_SMS" />
  <uses-permission android:name="android.permission.READ_SMS" />

Init SmsVerifyCatcher in method like onCreate activity:

    smsVerifyCatcher = new SmsVerifyCatcher(this, new OnSmsCatchListener<String>() {
        @Override
        public void onSmsCatch(String message) {
            String code = parseCode(message);//Parse verification code
            etCode.setText(code);//set code in edit text
            //then you can send verification code to server
        }
    });

Override activity lifecicle methods:

    @Override
    protected void onStart() {
        super.onStart();
        smsVerifyCatcher.onStart();
    }

    @Override
    protected void onStop() {
        super.onStop();
        smsVerifyCatcher.onStop();
    }

    /**
     * need for Android 6 real time permissions
     */
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        smsVerifyCatcher.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

You can set phone number filter:

    smsVerifyCatcher.setPhoneNumberFilter("777");

or set message filter via regexp:

   smsVerifyCatcher.setFilter("<regexp>");

That's all! Take a look at the sample project for more information

License

Copyright 2017 stfalcon.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

smsverifycatcher's People

Contributors

abhay222 avatar ahmedla avatar alexz89ua avatar bevzaanton avatar troy379 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smsverifycatcher's Issues

Misconfiguration of AndroidManifest.xml

Hello!

Could you remove from your AndroidManifest.xml lines inside application tag:

android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"

These lines are autogenerated by Android Studio, and not required for android modules. Their presence leads to conflicts, when I try to redefine these options in my AndroidManifest.xml. So I need to do some weird workaround.

Thank you

B

Acc

ArrayIndexOutOfBound

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.stfalcon.smsverifycatcher.SmsVerifyCatcher.onStart(Unknown Source)
at com.text.verify.onRequestPermissionsResult(Unknown Source)

onRequestPermissionsResult deprecated method in 'androidx.fragment.app.Fragment'

@Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        smsVerifyCatcher.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

How to convert it into registerForActivityResult()???

Service Not Register

When a user decline the permission request during start of the application, and when user decline the permission, SmsVerifyCatcher.onStart() is not run as permission is not granted. And in SmsVerifyCatcher onStart(), it is defined that register service when permission granted but omStop() there is no such condition, which is resulting in an exception.

java.lang.ArrayIndexOutOfBoundsException: length=0; index=0

Hi, I have a problem with the library, is there any way to handle this exception the first time i run the app.

When is the first time I run my app after installing it all over again, whenever my code wants to send the permission request to the user, it throws that error, but only the first time i run it; the rest works perfecttly. when i uninstall and reinstall the app, the first time it runs, it throws that error again.

Could you please help me?

Thanks in advance.

Setfilter with regex not working

I am trying to set filter for SMS it should have any prefix but must have a string AASDYW. It's not working. Any example? I get SMS from say IM-AASDYW or AD-AASDYW etc.

I am unable to set message code on edit text

I have download project and run this project then i am unable to get callback on

smsVerifyCatcher = new SmsVerifyCatcher(this, new OnSmsCatchListener() {
@OverRide
public void onSmsCatch(String message) {
String code =parseCode(message);//Parse verification code
etCode.setText(code);//set code in edit text

            Toast.makeText(MainActivity.this,"click",Toast.LENGTH_LONG).show();
            //then you can send verification code to server
        }
    }); please tell where am doing wrong any more thing we have to set?

Duplicate method

Duplicate class com.stfalcon.smsverifycatcher.OnSmsCatchListener found in modules jetified-SmsVerifyCatcher-0.3.3-runtime (com.github.stfalcon-studio:SmsVerifyCatcher:0.3.3) and jetified-smsverifycatcher-0.3.2-runtime (com.github.stfalcon:smsverifycatcher:0.3.2)

It's not work

My phone is 6.0 version, I can accept sms,but app isn't work

Migrate android 4.0

Hi, your library is awesome but i need that for android 4.0, please help me...

Scrde_otp_base

Thanks you so much only miss that in my base in so grateful for both of your work thanks

Just a query

Hi, amazing library. Though I just have a question. How do i get only 4/5 digit code from any message irrespective of its content. Also i didn't understood below statement:
Pattern p = Pattern.compile("\\b\\d{4}\\b");
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.