title: Read OTP/SMS in MI device not working (Android)
body: <p>I have integrated <strong><code>Auto read OTP</code></strong> in my code and it's working fine except in <strong>MIUI</strong> devices. <code>BroadcastReceiver</code> never wake up in case of <strong>MI devices</strong> when <code>sms</code> is received. After some efforts I think <code>MI devices</code> runs on its <code>Permission Manager</code> where all <code>Permissions</code> regarding read <code>sms</code> are disabled by default as comes in category of <code>Privacy permissions</code> and it looks like this : <a href="https://i.stack.imgur.com/WKV9L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WKV9L.png" alt="enter image description here"></a></p>
  
  <p>Now I can't figure out any way to Notify user first to accept or decline the Permission. Device simply disable the permissions by default after app is Installed in device.Is there any way to notify user to Accept the Permission's when app Installed ?</p>
  
  <p>Some code:</p>
  
  <p><strong>SMSReciever.class</strong> - <code>BroadcastReceiver</code> wakes up when SMS is received.</p>
  
  <pre><code>public class SMSReciever extends BroadcastReceiver {
  private static final String OTP_LENGTH = "6";
  private String otp = "";
  private IMessageCallback callable;
  private static final String TAG = SMSReciever.class.getSimpleName();
  
  @Override
  public void onReceive(Context context, Intent intent) {
      Bundle bundle = intent.getExtras();
      SmsMessage[] msgs = null;
  
      if (bundle != null) {
  
          Object[] pdus = (Object[]) bundle.get("pdus");
          msgs = new SmsMessage[pdus.length];
  
          for (int i = 0; i &lt; msgs.length; i++) {
  
              msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
  
              try {
                  String sender = msgs[i].getOriginatingAddress();
  
                  String phoneNumber = msgs[i].getDisplayOriginatingAddress();
                  Log.d(TAG, "onReceive: phone " + phoneNumber);
                  String message = msgs[i].getMessageBody();
                  Log.d(TAG, "onReceive: phone " + message);
  
                  otp = GetOtp.extractOTP(message, OTP_LENGTH);
  
                  if (null != sender &amp;&amp; message.contains("OTP for AppName") &amp;&amp; !TextUtils.isEmpty(otp)) {
                      if (callable != null)
                          callable.getOtp(otp);
                  }
  
              } catch (IllegalArgumentException e) {
                  e.printStackTrace();
              }
          }
      }
  }
  
  public void setMessageCallable(IMessageCallback callable) {
      this.callable = callable;
  }
  
  public interface IMessageCallback {
      void getOtp(String otp);
  }
  }
  </code></pre>
  
  <p><code>AndridManifest.xml</code> - permissions to receive and read sms </p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.RECEIVE_SMS"/&gt;
  &lt;uses-permission android:name="android.permission.READ_SMS"/&gt;
  </code></pre>