Reputation: 159
I am using SMS intent to send a sms for user's phone number verification, according to the new Google permission restriction https://support.google.com/googleplay/android-developer/answer/9047303#alternatives. But the problem is I cannot able to close the messaging app and also couldn't get any callback for sms sent status.(Always returning same resultCode even on pressing back from message app)
I tried this to close the app, but its not working.
smsIntent.putExtra("exit_on_sent", true);
And also followed this answer Sending SMS via an Intent and know if the SMS has been sent or not but again it requires READ_SMS permission.
There is no proper solution for this.
Please suggest me how to achieve this or any other alternate solution. SMS sending is required for my app for Account verification.
Upvotes: 1
Views: 1130
Reputation: 11
I had similar issue with my application since the new Google policy on sending and receiving SMS
Unfortunately exit_on_sent is not supported by many SMS applications. And opening SMS default app with startActivityForResult will not return a different value whether the SMS was sent or not
The best solution would be to use a Third Party service on internet that provides an API to send SMS (but it will probably not be free)
I also tried to register a SMS content observer as described in Sending SMS via an Intent and know if the SMS has been sent or not => according to my experience the onChange event will be raised even if the READ_SMS permission is not granted (except on a Xiaomi that crashed ;-), however there will be very few details on the SMS sent (you won't even know if SMS is sent or received)
Then for automatically read SMS you can have 2 options : - use the Google's SMS retriever API (see https://developers.google.com/identity/sms-retriever/) - with API 26 and more, use the SmsManager.createAppSpecificSmsToken (see android sms verification without READ_SMS permission)
Upvotes: 1