androidgoogle-playsmsandroid-permissions

SMS Retriever API - permanent listener


From the documentation it says that the SMS Retriever API is only listening up to 5 minutes.

The SMS retrieval task will listen for up to five minutes for an SMS message that contains a unique string that identifies your app.

Is it possible to have it running all the time? Is it bad for battery life if I boot it up every five minutes?

Use case is receiving an SMS request that responds to SMS with location. We use SMS, not data, because our users are often in areas without data network. I am unable to get RECEIVE_SMS permission on Google Play (what I gather from "update rejected" email), but they will allow SEND_SMS.


Solution

  • Not possible to keep it running longer than 5 minutes.

    Also, it listens for only one SMS with OTP, so it doesn't make sense even if it would have been longer than 5 minutes.

    If you have a resend OTP or retry functionality, you need to start the SMS retriever again with below code.

    val client = SmsRetriever.getClient(this)
    val retriever = client.startSmsRetriever()