0

I have used the sms permission in manifest file for sending the sms in offline by using sms manager but google didn't accept the declartion form which i have checked the device automation or default sms handler or default assistant handler, so the app has been rejected most of the times from the play store.

How to handle this problem because I have to use the sms in the app.

Please help me to find the solution. Thanks in advance

Manifest:

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

Code:

SmsManager sms = SmsManager.getDefault();
    ArrayList<String> parts = sms.divideMessage(message);

    ArrayList<PendingIntent> sendList = new ArrayList<>();
    sendList.add(sentPI);

    ArrayList<PendingIntent> deliverList = new ArrayList<>();
    deliverList.add(deliveredPI);

    sms.sendMultipartTextMessage(phoneNumber, null, parts, sendList, deliverList);
    Toast.makeText(context, "SMS sent.",
            Toast.LENGTH_LONG).show();

    //we unsubscribed in 10 seconds
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            context.unregisterReceiver(smsUtils);
        }
    }, 10000);
Ahmad Sabeh
  • 526
  • 5
  • 18
hem
  • 311
  • 1
  • 5
  • 16

1 Answers1

0

Sms Retriever Client (SmsRetrieverClient) api is way to go. It delivers the sms only to your app instead of broadcasting to all other apps who may be interested in getting sms by using some unique App Hash Key.

This don't requires you to add permissions in your manifest.

Here is how you can implement yours..

Automatic Sms verification Google Play Services

The SMS Retriever API is available only on Android devices with Play services version 10.2 and newer.

vikas kumar
  • 10,447
  • 2
  • 46
  • 52
  • This one I can't use i just simply send the sms to user – hem Mar 18 '19 at 10:11
  • in that case you have to open default sms sender app via intent. – vikas kumar Mar 18 '19 at 10:28
  • yes but i need to send the sms automatically to user, suppose if i use sms via intent i have to do it manually send the sms to user – hem Mar 18 '19 at 10:35
  • As I understand **Sms Retriever Client** will wait only for 5 minutes for an incoming message. How to overcome this restriction if I would like to get incoming SMS which was sent any time to me? – isabsent Mar 18 '19 at 10:54
  • this restriction is for app in foreground only which is ideal case. but if you are interested in listening for longer time move it to some background thread and use Tasks.await(task,10000, TimeUnit.MILLISECONDS); haven't tested but worth a try. – vikas kumar Mar 18 '19 at 13:42
  • @vikas kumar If a device does not have Play services version 10.2 or newer and they try to run an app that uses SMS Retriever, will the app just fail or will the user be brought to the Play Store to upgrade to the latest version of Play services? Can the developer add code in the app to elegantly handle the fail by bringing the user to the Play Store to do the upgrade of Play services? – AJW Jul 15 '20 at 15:49
  • 1
    Hi @AJW I guess you can force the user to update the play services in your app. here is thread for it. https://stackoverflow.com/questions/27604213/how-to-check-if-google-play-services-is-up-to-date – vikas kumar Jul 15 '20 at 16:03