From c22fcf77fca69c18abebc4b1a937cfab8271f339 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sun, 7 Jan 2018 22:21:41 +0530 Subject: [PATCH] [Fix] OTP Catcher --- .../otpmobileauth/auth/SMSBroadcastReceiver.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/mntechnique/otpmobileauth/auth/SMSBroadcastReceiver.kt b/app/src/main/kotlin/com/mntechnique/otpmobileauth/auth/SMSBroadcastReceiver.kt index e7f7095..3359824 100644 --- a/app/src/main/kotlin/com/mntechnique/otpmobileauth/auth/SMSBroadcastReceiver.kt +++ b/app/src/main/kotlin/com/mntechnique/otpmobileauth/auth/SMSBroadcastReceiver.kt @@ -22,10 +22,11 @@ class SMSBroadcastReceiver : BroadcastReceiver() { var bundle = intent.extras if (bundle != null) { - var pdus:Array = bundle.get("pdus") as Array + var pdus:Array = bundle.get("pdus") as Array for (i in 0..pdus.size -1) { - var message:SmsMessage? = null + var message:SmsMessage? = SmsMessage.createFromPdu(pdus[i] as ByteArray) + when(context.telephonyManager.phoneType) { TelephonyManager.PHONE_TYPE_GSM -> { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { @@ -39,11 +40,11 @@ class SMSBroadcastReceiver : BroadcastReceiver() { } } - var senderNum = message?.displayOriginatingAddress - var messageBody = message?.displayMessageBody + var senderNum = message?.originatingAddress + var messageBody = message?.messageBody - Log.d("Number", message?.originatingAddress) - Log.d("SMS", message?.messageBody) + Log.d("Number", senderNum) + Log.d("SMS", messageBody) var smsIntent = Intent("otp") smsIntent.putExtra("message", messageBody)