diff --git a/SmsOtpAutoVerifyPlugin.kt b/SmsOtpAutoVerifyPlugin.kt new file mode 100644 index 00000000..a6fafd90 --- /dev/null +++ b/SmsOtpAutoVerifyPlugin.kt @@ -0,0 +1,216 @@ +package com.oohyugi.sms_otp_auto_verify + +import android.app.Activity +import android.app.PendingIntent +import android.content.Context +import android.content.Intent + +import android.content.IntentFilter +import android.content.IntentSender +import android.os.Build +import android.telephony.TelephonyManager +import android.util.Log +import androidx.annotation.RequiresApi +import com.google.android.gms.auth.api.credentials.Credential +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.MethodChannel.MethodCallHandler; +import com.google.android.gms.auth.api.phone.SmsRetriever; +import com.google.android.gms.auth.api.phone.SmsRetrieverClient +import io.flutter.embedding.engine.plugins.FlutterPlugin +import io.flutter.embedding.engine.plugins.activity.ActivityAware +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding +import io.flutter.plugin.common.BinaryMessenger +import io.flutter.plugin.common.PluginRegistry +import com.google.android.gms.auth.api.credentials.Credentials +import com.google.android.gms.auth.api.credentials.HintRequest +import io.flutter.plugin.common.PluginRegistry.Registrar +import androidx.core.content.ContextCompat +import androidx.core.content.ContextCompat.RECEIVER_EXPORTED + + +/** SmsOtpAutoVerifyPlugin */ +class SmsOtpAutoVerifyPlugin : FlutterPlugin, MethodCallHandler, + MySmsListener, ActivityAware { + private var channel: MethodChannel? = null + private var pendingResult: MethodChannel.Result? = null + private var receiver: SmsBroadcastReceiver? = null + private var alreadyCalledSmsRetrieve = false + private var client: SmsRetrieverClient? = null + private var activity: Activity? = null + private var binding: ActivityPluginBinding? = null + + private val activityResultListener: PluginRegistry.ActivityResultListener = + object : PluginRegistry.ActivityResultListener { + override fun onActivityResult( + requestCode: Int, + resultCode: Int, + data: Intent? + ): Boolean { + if (requestCode == REQUEST_RESOLVE_HINT) { + if (resultCode == Activity.RESULT_OK && data != null) { + val credential: Credential? = data.getParcelableExtra(Credential.EXTRA_KEY) + val phoneNumber: String? = credential?.id + pendingResult?.success(phoneNumber) + } else { + pendingResult?.success(null) + } + return true + } + return false + } + } + + companion object { + private const val channelName = "sms_otp_auto_verify" + private const val REQUEST_RESOLVE_HINT = 1256 + + @JvmStatic + fun setup(plugin: SmsOtpAutoVerifyPlugin, binaryMessenger: BinaryMessenger) { + plugin.channel = MethodChannel(binaryMessenger, channelName) + plugin.channel?.setMethodCallHandler(plugin) + plugin.binding?.addActivityResultListener(plugin.activityResultListener) + + } + } + + + override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) { + setup(plugin = this, binding.binaryMessenger) + } + + override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) { + unregister() + } + + @RequiresApi(Build.VERSION_CODES.O) + override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { + when (call.method) { + "getAppSignature" -> { + activity?.let { + val signature = AppSignatureHelper(it).getAppSignatures()[0] + result.success(signature) + } + + } + + "startListening" -> { + this.pendingResult = result + receiver = SmsBroadcastReceiver() + startListening() + + } + + "stopListening" -> { + pendingResult = null + unregister() + } + + "requestPhoneHint" -> { + this.pendingResult = result + requestHint() + + } + + else -> result.notImplemented() + } + } + + private fun requestHint() { + if (!isSimSupport()) { + pendingResult?.success(null) + return + } + + val hintRequest = HintRequest.Builder() + .setPhoneNumberIdentifierSupported(true) + .build() + + activity?.apply { + val intent = Credentials.getClient(this).getHintPickerIntent(hintRequest) + try { + startIntentSenderForResult( + intent.intentSender, + REQUEST_RESOLVE_HINT, null, 0, 0, 0 + ) + } catch (e: IntentSender.SendIntentException) { + e.printStackTrace() + } + } + } + + private fun isSimSupport(): Boolean { + val telephonyManager: TelephonyManager = + activity!!.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager + return (telephonyManager.simState == TelephonyManager.SIM_STATE_ABSENT) + } + + @RequiresApi(Build.VERSION_CODES.O) + private fun startListening() { + activity?.let { + client = SmsRetriever.getClient(it) + } + val task = client?.startSmsRetriever() + task?.addOnSuccessListener { + // Successfully started retriever, expect broadcast intent + unregister() + Log.e(javaClass::getSimpleName.name, "task started") + receiver?.setSmsListener(this) + + activity?.applicationContext?.let { it1 -> + ContextCompat.registerReceiver( + it1, receiver, + IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION), RECEIVER_EXPORTED) + } + } + } + + private fun unregister() { + alreadyCalledSmsRetrieve = false + if (receiver != null) { + try { + activity?.unregisterReceiver(receiver) + Log.d(javaClass::getSimpleName.name, "task stoped") + receiver = null + } catch (e: Exception) { + } + } + } + + override fun onOtpReceived(message: String?) { + message?.let { + if (!alreadyCalledSmsRetrieve) { + pendingResult?.success(it) + alreadyCalledSmsRetrieve = true + } else { + Log.d("onOtpReceived: ", "already called") + } + } + + } + + override fun onOtpTimeout() { + } + + + override fun onAttachedToActivity(binding: ActivityPluginBinding) { + activity = binding.activity + this.binding = binding + binding.addActivityResultListener(activityResultListener); } + + override fun onDetachedFromActivityForConfigChanges() { + unregister() + } + + override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { + activity = binding.activity + this.binding = binding + binding.addActivityResultListener(activityResultListener); + } + + override fun onDetachedFromActivity() { + unregister() + } + + +} diff --git a/android/build.gradle b/android/build.gradle index e723adba..78038517 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.7.20' + ext.kotlin_version = '1.8.0' repositories { google() jcenter() diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 70c9bd9b..1514bc24 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -540,7 +540,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.5.82; + MARKETING_VERSION = 4.5.84; PRODUCT_BUNDLE_IDENTIFIER = "com.HMG.HMG-Smartphone"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -684,7 +684,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.5.82; + MARKETING_VERSION = 4.5.84; PRODUCT_BUNDLE_IDENTIFIER = "com.HMG.HMG-Smartphone"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -722,7 +722,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - MARKETING_VERSION = 4.5.82; + MARKETING_VERSION = 4.5.84; PRODUCT_BUNDLE_IDENTIFIER = "com.HMG.HMG-Smartphone"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/lib/config/config.dart b/lib/config/config.dart index 09255501..e7013cf6 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -343,7 +343,7 @@ var UPDATE_COVID_QUESTIONNAIRE = 'Services/Doctors.svc/REST/COVID19_Questionnari var CHANNEL = 3; var GENERAL_ID = 'Cs2020@2016\$2958'; var IP_ADDRESS = '10.20.10.20'; -var VERSION_ID = 12.1; +var VERSION_ID = 12.3; var SETUP_ID = '91877'; var LANGUAGE = 2; // var PATIENT_OUT_SA = 0; diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index 37161678..d16c6579 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -1282,7 +1282,7 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { DoctorsListService service = new DoctorsListService(); service .insertVIDARequest(appo.appointmentNo, appo.clinicID, appo.projectID, appo.serviceID, appo.doctorID, appo.appointmentDate, - Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), projectViewModel.isArabic ? 1 : 2, context) + transID, projectViewModel.isArabic ? 1 : 2, context) .then((res) { GifLoaderDialogUtils.hideDialog(context); getPatientAppointmentHistory(); diff --git a/lib/pages/livecare/widgets/clinic_list.dart b/lib/pages/livecare/widgets/clinic_list.dart index 0e1ba5aa..1dbf72e4 100644 --- a/lib/pages/livecare/widgets/clinic_list.dart +++ b/lib/pages/livecare/widgets/clinic_list.dart @@ -386,7 +386,7 @@ class _clinic_listState extends State { applePayInsertRequest.appointmentDate = appo.appointmentDate; applePayInsertRequest.appointmentNo = appo.appointmentNo; applePayInsertRequest.orderDescription = "LiveCare Payment"; - applePayInsertRequest.liveServiceID = "0"; + applePayInsertRequest.liveServiceID = selectedClinicID.toString(); applePayInsertRequest.latitude = "0.0"; applePayInsertRequest.longitude = "0.0"; applePayInsertRequest.amount = amount; diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index c9fecbf9..c71b206b 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -40,9 +40,9 @@ class MyInAppBrowser extends InAppBrowser { // static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL LIVE static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL UAT - // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT + static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT - static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE + // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE // static String SERVICE_URL = 'https://uat.hmgwebservices.com/payfortforvidaplus/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL UAT VIDA PLUS diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 64c981b2..d1affc14 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -103,7 +103,7 @@ class SMSOTP { startTimer(setState); // startLister(); - if (Platform.isAndroid) checkSignature(); + if (Platform.isAndroid && type == 1) checkSignature(); } return Container( diff --git a/pubspec.yaml b/pubspec.yaml index 2a44171b..addd6356 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: diplomaticquarterapp description: A new Flutter application. -version: 4.5.046+4050046 +version: 4.5.84+1 environment: sdk: ">=2.7.0 <3.0.0"