diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 0bd786ec..e216dae5 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,51 +1,82 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ FlutterApplication and put your custom class here.
+ -->
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
+
+
@@ -53,111 +84,146 @@
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
+
+
+ android:icon="@mipmap/ic_launcher_local"
+ android:label="Dr. Alhabib"
+ android:screenOrientation="sensorPortrait"
+ android:showOnLockScreen="true"
+ android:usesCleartextTraffic="true"
+ tools:replace="android:extractNativeLibs,android:label">
+
+
+
+
+
+
+
-
-
+ to determine the Window background behind the Flutter UI.
+ -->
-
+ Flutter's first frame.
+ -->
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
-
-
-
+
+
+
-
+
@@ -173,26 +239,17 @@
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/MainActivity.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/MainActivity.kt
index d51e25ec..c874ea4d 100644
--- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/MainActivity.kt
+++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/MainActivity.kt
@@ -1,4 +1,5 @@
package com.ejada.hmg
+import android.app.PendingIntent
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
@@ -7,6 +8,7 @@ import android.view.WindowManager
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi
import com.cloud.diplomaticquarterapp.PenguinInPlatformBridge
+import com.cloud.diplomaticquarterapp.whatsapp.AppSignatureRetriever
import com.ejada.hmg.utils.*
import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
@@ -26,11 +28,8 @@ class MainActivity: FlutterFragmentActivity() {
OpenTokPlatformBridge(flutterEngine, this).create()
PenguinInPlatformBridge(flutterEngine, this).create()
WhatsAppOtpPlatformBridge(flutterEngine, this).invoke()
- WhatsApp.handleOTP(intent){code ->
- WhatsAppOtpPlatformBridge.result?.success(code);
- }
-
-// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ AppSignatureRetriever().logSignatures(this)
+// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {x
// val mChannel = NotificationChannel("video_call_noti", "video call", NotificationManager.IMPORTANCE_HIGH)
// val soundUri = Uri.parse("android.resource://" + getApplicationContext()
// .getPackageName() + "/" + R.raw.alert)
diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/AppSignatureRetriever.java b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/AppSignatureRetriever.java
new file mode 100644
index 00000000..83e6e917
--- /dev/null
+++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/AppSignatureRetriever.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+package com.cloud.diplomaticquarterapp.whatsapp;
+
+import static java.sql.DriverManager.println;
+
+import android.content.Context;
+import android.content.ContextWrapper;
+import android.content.pm.PackageManager;
+import android.content.pm.Signature;
+import android.util.Base64;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.stream.Collectors;
+
+public class AppSignatureRetriever {
+
+ private static final String HASH_TYPE = "SHA-256";
+ public static final int NUM_HASHED_BYTES = 9;
+ public static final int NUM_BASE64_CHAR = 11;
+
+
+ public void logSignatures(Context context) {
+ Collection appSignatures = getAppSignatures(context);
+ appSignatures.forEach(signature -> println("Signature: " + signature));
+ }
+
+ /**
+ * Get all the app signatures for the current package.
+ *
+ * @return signatures for current app
+ */
+ public Collection getAppSignatures(Context context) {
+ try {
+ // Get all package signatures for the current package
+ String packageName = context.getPackageName();
+ println("Package name: " + packageName);
+ PackageManager packageManager = context.getPackageManager();
+ Signature[] signatures = packageManager.getPackageInfo(packageName,
+ PackageManager.GET_SIGNATURES).signatures;
+
+ // For each signature create a compatible hash
+ Collection appCodes = Arrays.stream(signatures)
+ .map(signature -> hash(packageName, signature.toCharsString()))
+ .collect(Collectors.toList());
+ return appCodes;
+ } catch (PackageManager.NameNotFoundException e) {
+ println("Unable to find package to obtain hash.");
+ throw new RuntimeException("Unable to find package to obtain hash.", e);
+ }
+
+ }
+
+ private String hash(String packageName, String signature) {
+ String appInfo = packageName + " " + signature;
+ try {
+ MessageDigest messageDigest = MessageDigest.getInstance(HASH_TYPE);
+ messageDigest.update(appInfo.getBytes(StandardCharsets.UTF_8));
+ byte[] hashSignature = messageDigest.digest();
+
+ // truncated into NUM_HASHED_BYTES
+ hashSignature = Arrays.copyOfRange(hashSignature, 0, NUM_HASHED_BYTES);
+ // encode into Base64
+ String base64Hash = Base64.encodeToString(hashSignature, Base64.NO_PADDING | Base64.NO_WRAP);
+ base64Hash = base64Hash.substring(0, NUM_BASE64_CHAR);
+
+ println(String.format("pkg: %s -- hash: %s", packageName, base64Hash));
+ return base64Hash;
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException("Unable to generate hash for application", e);
+ }
+ }
+}
diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/WhatsApp.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/WhatsApp.kt
index 6d16745d..73452e6f 100644
--- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/WhatsApp.kt
+++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/WhatsApp.kt
@@ -14,7 +14,11 @@ object WhatsApp {
intent,
// call your function to validate
{code -> validateOTP(code) },
- {_,_->})
+ {error,exception->
+ println("the error is ${error.name}")
+ println("the exception stacktrace is ${exception.message}")
+ println("the exception is cause ${exception.cause}")
+ })
fun performHandShake(context : WeakReference) = whatsAppOtpHandler.sendOtpIntentToWhatsApp(context.get()!!)
diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/WhatsAppCodeActivity.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/WhatsAppCodeActivity.kt
new file mode 100644
index 00000000..5862b30b
--- /dev/null
+++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/whatsapp/WhatsAppCodeActivity.kt
@@ -0,0 +1,18 @@
+package com.ejada.hmg
+import android.app.PendingIntent
+import android.content.Intent
+import android.os.Bundle
+import com.cloud.diplomaticquarterapp.whatsapp.WhatsApp
+import com.cloud.diplomaticquarterapp.whatsapp.WhatsAppOtpPlatformBridge
+import io.flutter.embedding.android.FlutterFragmentActivity
+
+class WhatsAppCodeActivity : FlutterFragmentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ WhatsApp.handleOTP(intent){code ->
+ WhatsAppOtpPlatformBridge.result?.success(code);
+ println("the code is $code")
+ finish()
+ }
+ }
+}
\ No newline at end of file
diff --git a/android/app/src/main/res/layout/activity_whats_app_code.xml b/android/app/src/main/res/layout/activity_whats_app_code.xml
new file mode 100644
index 00000000..95bd5d8b
--- /dev/null
+++ b/android/app/src/main/res/layout/activity_whats_app_code.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 1093435a..6c4ac3df 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -1,23 +1,23 @@
- HMG Patient App
+ HMG Patient App
-
+
Unknown error: the Geofence service is not available now.
-
+
Geofence service is not available now. Go to Settings>Location>Mode and choose High accuracy.
-
+
Your app has registered too many geofences.
-
+
You have provided too many PendingIntents to the addGeofences() call.
-
+
App do not have permission to access location service.
-
+
Geofence requests happened too frequently.
- sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg
+ sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg
diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart
index aabea14c..1c17088b 100644
--- a/lib/pages/login/confirm-login.dart
+++ b/lib/pages/login/confirm-login.dart
@@ -346,10 +346,16 @@ class _ConfirmLogin extends State {
}
loginWithSMS(type) async {
- // if (type == 4) {
- // var channel = WhatsappMethodChannel();
- // await channel.handleHandShake();
- // }
+ if (type == 4) {
+ var channel = WhatsappMethodChannel();
+ // var whatsappStatus = await channel.isWhatsAppInstalled();
+ // if(whatsappStatus) {
+ // print("whatapp is installed");
+ channel.handleHandShake();
+ // }else{
+ // print("whatapp is not installed");
+ // }
+ }
//if (!el.disabled) {
if (this.user != null && this.registerd_data == null) {
diff --git a/lib/uitl/whatsapp_method_channel.dart b/lib/uitl/whatsapp_method_channel.dart
index 20d26159..068e123e 100644
--- a/lib/uitl/whatsapp_method_channel.dart
+++ b/lib/uitl/whatsapp_method_channel.dart
@@ -24,9 +24,11 @@ class WhatsappMethodChannel {
Future startListening() async {
try{
- return await _channel.invokeMethod("startListening");
+ String code = await _channel.invokeMethod("startListening");
+ print("the code in flutter is ${code}");
+ return code;
}catch(e){
return "";
}
}
-}
+}
\ No newline at end of file
diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart
index 5c30605a..66bdb936 100644
--- a/lib/widgets/otp/sms-popup.dart
+++ b/lib/widgets/otp/sms-popup.dart
@@ -103,9 +103,10 @@ class SMSOTP {
child: StatefulBuilder(builder: (context, setState) {
if (displayTime == '') {
startTimer(setState);
-
- // startLister();
- if (Platform.isAndroid && type == 1) checkSignature();
+ if (Platform.isAndroid ) {
+ if (type == 1) checkSignature();
+ else if(type == 4) _listenWhatsAppCode();
+ }
}
return Container(
@@ -297,17 +298,15 @@ class SMSOTP {
SmsVerification.stopListening();
// });
});
+ }
+ void _listenWhatsAppCode(){
WhatsappMethodChannel().startListening().then((message) {
- // setState(() {
final intRegex = RegExp(r'\d+', multiLine: true);
var otp = SmsVerification.getCode(message, intRegex);
_pinPutController.text = otp;
onSuccess(otp);
- SmsVerification.stopListening();
- // });
});
-
}
// startLister() {