Rajat421 / react-native-sms-retriever-api

Checkout my blog to have clear understanding whats this package does
https://medium.com/groww-engineering/google-sms-retriever-api-integration-with-react-native-fab31947f438
11 stars 10 forks source link

Remove listener #7

Open shubham2102 opened 4 years ago

shubham2102 commented 4 years ago

How can we remove the listener? As of now everything works fine but the listener is not getting removed. I've tried

SmsListener.removeListener();

And I am getting error:

TypeError: TypeError: _reactNativeAndroidSmsListener.default.removeListener is not a function.

shubham2102 commented 4 years ago

Any leads??

Rajat421 commented 4 years ago

Hi, @shubham2102 I am not maintaining this repo now, you can fix this issue yourself

just add


    public void unRegisterListener() {
        Log.d(TAG, "unregister");
        unregisterReceiver(mReceiver);
    }```

in xxModule.java 
and call this instead of removeListener
Rajat421 commented 4 years ago

https://medium.com/groww-engineering/google-sms-retriever-api-integration-with-react-native-fab31947f438 checkout this blog for more clarity

let me know if you need more help.

Rajat421 commented 4 years ago

Will try to update the code by this weekend

shubham2102 commented 4 years ago

Hi @Rajat421 it's giving this error: WhatsApp Image 2019-12-30 at 7 42 59 PM

Code changes were:

@ReactMethod 
    public void unRegisterListener() { 
        // Log.d(TAG, "unregister"); 
        unregisterReceiver(mReceiver); 
    }

in RNSmsRetrieverModule.java

And I was accessing the unregister method in my application by:

            SmsListener.unRegisterListener();