diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/HMG_Guest.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/HMG_Guest.kt index 50968a4c..7b3cc2d1 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/HMG_Guest.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/HMG_Guest.kt @@ -2,26 +2,28 @@ package com.ejada.hmg.hmgwifi import android.annotation.SuppressLint import android.content.Context -import android.net.ConnectivityManager -import android.net.Network -import android.net.NetworkCapabilities -import android.net.NetworkRequest -import android.net.wifi.WifiConfiguration -import android.net.wifi.WifiManager -import android.net.wifi.WifiNetworkSpecifier +import android.content.Intent +import android.net.* +import android.net.wifi.* import android.os.Build +import android.os.PatternMatcher +import android.provider.Settings import android.util.Log import androidx.annotation.RequiresApi import com.ejada.hmg.MainActivity import com.ejada.hmg.utils.HMGUtils -class HMG_Guest(private var context: MainActivity) { - private var wifiManager: WifiManager? = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager? + + +class HMG_Guest(private var context: MainActivity, ssid: String) { private val TAG = "HMG_Guest" private val TEST = false - private var SSID = """"HMG-MobileApp"""" + private var SSID = ssid +// private var SSID = "HMG-MOHEMM" + + val wifiManager = context.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager? private lateinit var completionListener: ((status: Boolean, message: String) -> Unit) @@ -29,23 +31,30 @@ class HMG_Guest(private var context: MainActivity) { completionListener(status, message) } + fun enableWifi(){ + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q){ + wifiManager?.setWifiEnabled(true) + HMGUtils.popFlutterText(context,"enablingWifi"); + HMGUtils.timer(2000,false){ + connectApiLessThen29() + } + }else { + val panelIntent = Intent(Settings.Panel.ACTION_WIFI) + context.startActivityForResult(panelIntent, 1) + } + } /* * Helpful: * http://stackoverflow.com/questions/8818290/how-to-connect-to-a-specific-wifi-network-in-android-programmatically */ fun connectToHMGGuestNetwork(completion: (status: Boolean, message: String) -> Unit) { + completionListener = completion wifiManager?.let { wm -> - completionListener = completion - if (!wm.isWifiEnabled){ - wm.isWifiEnabled = true - HMGUtils.popFlutterText(context,"enablingWifi"); - HMGUtils.timer(2000,false){ - connectWifi() - } + enableWifi() + }else{ connectWifi() } - } } @@ -56,7 +65,7 @@ class HMG_Guest(private var context: MainActivity) { fun connectWifi(){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){ - wifiManager?.let { connectApiGreaterThen28(it) } + connectApiGreaterThen28() }else { connectApiLessThen29() } @@ -64,40 +73,48 @@ class HMG_Guest(private var context: MainActivity) { // I }else{f CompileSDK is greater and equals to APILevel 29 @RequiresApi(Build.VERSION_CODES.Q) - private fun connectApiGreaterThen28(wm:WifiManager){ + private fun connectApiGreaterThen28(){ Log.e(TAG, "connection wifi with Android Q+") - val wifiNetworkSpecifier: WifiNetworkSpecifier = WifiNetworkSpecifier.Builder() -// .setWpa2Passphrase(password) - .build() val networkRequest: NetworkRequest = NetworkRequest.Builder() - .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) - .setNetworkSpecifier(wifiNetworkSpecifier) - .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) //removeCapability added for hotspots without internet - .build() + .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) + .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) + .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) //removeCapability added for hotspots without internet + .setNetworkSpecifier( + WifiNetworkSpecifier.Builder() + .setSsid(SSID) + .build() + + ).build() val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager val networkCallback = object : ConnectivityManager.NetworkCallback() { override fun onAvailable(network: Network) { super.onAvailable(network) connectivityManager.bindProcessToNetwork(network) + HMGUtils.timer(2000,false){ + completionListener(true, "Success") + } Log.e(TAG, "onAvailable") } override fun onLosing(network: Network, maxMsToLive: Int) { super.onLosing(network, maxMsToLive) Log.e(TAG, "onLosing") + completionListener(false, "fail") } override fun onLost(network: Network) { super.onLost(network) Log.e(TAG, "onLosing") Log.e(TAG, "losing active connection") + completionListener(false, "fail") } override fun onUnavailable() { super.onUnavailable() Log.e(TAG, "onUnavailable") + completionListener(false, "fail") } } @@ -107,132 +124,117 @@ class HMG_Guest(private var context: MainActivity) { } - /** - * This method takes a given String, searches the current list of configured WiFi - * networks, and returns the networkId for the network if the SSID matches. If not, - * it returns -1. - */ - @SuppressLint("MissingPermission") - private fun ssidToNetworkId(ssid: String): Int { - val currentNetworks = wifiManager!!.configuredNetworks - var networkId = -1 - - // For each network in the list, compare the SSID with the given one - for (test in currentNetworks) { - if (test.SSID == ssid) { - networkId = test.networkId - break - } - } - return networkId - } - fun connectApiLessThen29(){ - if(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q){ - - // Initialize the WifiConfiguration object - val security = "OPEN" - val networkPass = "" - Log.d(TAG, "Connecting to SSID \"$SSID\" with password \"$networkPass\" and with security \"$security\" ...") + val wifi = WifiConfiguration() + wifi.SSID = """"$SSID"""" + wifi.status = WifiConfiguration.Status.ENABLED + wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE) + + wifi.networkId = ssidToNetworkId(wifi.SSID) + if (wifi.networkId == -1) { + wifiManager?.addNetwork(wifi) + } else { + Log.v(TAG, "WiFi found - updating it.\n") + wifiManager?.updateNetwork(wifi) + } - // You need to create WifiConfiguration instance like this: - val conf = WifiConfiguration() - conf.SSID = SSID - conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE) - conf.networkId = ssidToNetworkId(SSID) + Log.v(TAG, "saving config.\n") + wifiManager?.saveConfiguration() - val wm = wifiManager!! + wifi.networkId = ssidToNetworkId(wifi.SSID) - if (conf.networkId == -1) { - wm.addNetwork(conf) - } else { - Log.v(TAG, "WiFi found - updating it.\n") - wm.updateNetwork(conf) - } + Log.v(TAG, "wifi ID in device = " + wifi.networkId) - conf.networkId = ssidToNetworkId(SSID) - Log.d(TAG, "Network ID: ${conf.networkId}") - - val networkIdToConnect = conf.networkId - if (networkIdToConnect >= 0) { - Log.v(TAG, "Start connecting to $SSID Wifi...") - - // We disable the network before connecting, because if this was the last connection before - // a disconnect(), this will not reconnect. - wm.disableNetwork(networkIdToConnect) - val result = wm.enableNetwork(networkIdToConnect, true) - if(result){ - HMGUtils.timer(8000,false){ - if(wm.getConnectionInfo().getSSID() == SSID){ - completionOnUiThread(true, "successConnectingHmgNetwork") - - }else{ - errorConnecting() - } - } - - }else{ - errorConnecting() - } + var supState: SupplicantState + val networkIdToConnect = wifi.networkId + if (networkIdToConnect >= 0) { + Log.v(TAG, "Start connecting...\n") + // We disable the network before connecting, because if this was the last connection before + // a disconnect(), this will not reconnect. + wifiManager?.disableNetwork(networkIdToConnect) + wifiManager?.enableNetwork(networkIdToConnect, true) + val wifiInfo: WifiInfo = wifiManager!!.connectionInfo - }else{ - Log.v(TAG, "Cannot connect to $SSID network") - errorConnecting() + HMGUtils.timer(5000,false){ + supState = wifiInfo.supplicantState + Log.i(TAG, "Done connect to network : status = $supState") + val successStates = listOf(SupplicantState.COMPLETED, SupplicantState.ASSOCIATED) + if (successStates.contains(supState)) + completionListener(true,"Connected to internet Wifi") + else + completionListener(false,"errorConnectingHmgNetwork") } - } - /*val wifi = WifiConfiguration(); - wifi.hiddenSSID = this.hiddenSSID; - wifi.SSID = newSSID; - wifi.preSharedKey = newPass; - wifi.status = WifiConfiguration.Status.ENABLED; - wifi.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); - wifi.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); - wifi.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); - wifi.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); - wifi.allowedProtocols.set(WifiConfiguration.Protocol.RSN); - wifi.allowedProtocols.set(WifiConfiguration.Protocol.WPA); - - wifi.networkId = ssidToNetworkId(newSSID); - - // Set network to highest priority (deprecated in API >= 26) - if(Build.VERSION.SDK_INT < 26) { - wifi.priority = getMaxWifiPriority(wifiManager) + 1; + } else { + Log.v(TAG, "WifiWizard: cannot connect to network") + completionListener(false,"errorConnectingHmgNetwork") } - // After processing authentication types, add or update network - if(wifi.networkId == -1) { // -1 means SSID configuration does not exist yet - - int newNetId = wifiManager.addNetwork(wifi); - if( newNetId > -1 ){ - callbackContext.success( newNetId ); - } else { - callbackContext.error( "ERROR_ADDING_NETWORK" ); - } - - } else { +// val wifi = WifiConfiguration() +// wifi.SSID = SSID +// wifi.status = WifiConfiguration.Status.ENABLED +// wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); +// +// wifi.networkId = ssidToNetworkId(SSID) +// +// // Set network to highest priority (deprecated in API >= 26) +// if(Build.VERSION.SDK_INT < 26) { +// wifi.priority = getMaxWifiPriority(wifiManager!!) + 1; +// } +// +// // After processing authentication types, add or update network +// if(wifi.networkId == -1) { // -1 means SSID configuration does not exist yet +// +// val newNetId = wifiManager?.addNetwork(wifi)!! +// if( newNetId > -1 ){ +// completionListener(true,"Success") +// } else { +// completionListener(false, "ERROR_ADDING_NETWORK" ) +// } +// +// } else { +// +// var updatedNetID = wifiManager?.updateNetwork(wifi) +// +// if(updatedNetID == -1) +// updatedNetID = wifiManager?.addNetwork(wifi) +// +// if(updatedNetID > -1) { +// callbackContext.success( updatedNetID ) +// } else { +// callbackContext.error("ERROR_UPDATING_NETWORK") +// } +// +// } +// +// // WifiManager configurations are presistent for API 26+ +// if(Build.VERSION.SDK_INT < 26) { +// wifiManager?.saveConfiguration(); // Call saveConfiguration for older < 26 API +// } + } - int updatedNetID = wifiManager.updateNetwork(wifi); - if(updatedNetID == -1) - updatedNetID = wifiManager.addNetwork(wifi); + /** + * This method takes a given String, searches the current list of configured WiFi + * networks, and returns the networkId for the network if the SSID matches. If not, + * it returns -1. + */ + @SuppressLint("MissingPermission") + private fun ssidToNetworkId(ssid: String): Int { + val currentNetworks = wifiManager!!.configuredNetworks + var networkId = -1 - if(updatedNetID > -1) { - callbackContext.success( updatedNetID ); - } else { - callbackContext.error("ERROR_UPDATING_NETWORK"); + // For each network in the list, compare the SSID with the given one + for (test in currentNetworks) { + if (test.SSID == ssid) { + networkId = test.networkId + break } - } - - // WifiManager configurations are presistent for API 26+ - if(API_VERSION < 26) { - wifiManager.saveConfiguration(); // Call saveConfiguration for older < 26 API - }*/ + return networkId } companion object{ diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/HMG_Internet.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/HMG_Internet.kt index c55040b3..dcfa5488 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/HMG_Internet.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/HMG_Internet.kt @@ -20,14 +20,11 @@ class HMG_Internet(flutterMainActivity: MainActivity) { private lateinit var completionListener: ((status: Boolean, message: String) -> Unit) private var SSID = "GUEST-POC" - private var USER_NAME = "" - private var PASSWORD = "" fun completionOnUiThread(status: Boolean, message: String){ completionListener(status, message) // context.runOnUiThread { -// -// FlutterText.with(message){localized -> +// .with(message){localized -> // completionListener(status, localized) // } // } @@ -37,12 +34,10 @@ class HMG_Internet(flutterMainActivity: MainActivity) { * Helpful: * http://stackoverflow.com/questions/8818290/how-to-connect-to-a-specific-wifi-network-in-android-programmatically */ - fun connectToHMGGuestNetwork(patientId: String, completion: (status: Boolean, message: String) -> Unit): HMG_Internet { + fun connectToHMGGuestNetwork(username: String, password: String, completion: (status: Boolean, message: String) -> Unit): HMG_Internet { completionListener = completion - getWifiCredentials(patientId) { - WpaEnterprise(context,SSID).connect(USER_NAME,PASSWORD) { status, message -> - completionOnUiThread(status,message) - } + WpaEnterprise(context,SSID).connect(username,username) { status, message -> + completionOnUiThread(status,message) } return this } @@ -65,16 +60,28 @@ class HMG_Internet(flutterMainActivity: MainActivity) { } } - private fun getWifiCredentials(patientId:String, success: (() -> Unit)){ + private fun getWifiCredentials(patientId:String, success: ((String?,String?) -> Unit)){ if (TEST){ SSID = "GUEST-POC" - USER_NAME = "0696" - PASSWORD = "0000" - success() + success("2300", "0000") return } - val jsonBody = """{"PatientID":$patientId}""" + val jsonBody = """{ + "PatientID":$patientId + "VersionID": 8.8, + "Channel": 3, + "LanguageID": 2, + "IPAdress": "10.20.10.20", + "generalid": "Cs2020@2016$2958", + "PatientOutSA": 0, + "SessionID": "@admin", + "isDentalAllowedBackend": false, + "DeviceTypeID": 2, + "TokenID": "@admin", + "PatientTypeID": 1, + "PatientType": 1 + }""".trimMargin() API.WIFI_CREDENTIALS. httpPost() .jsonBody(jsonBody, Charsets.UTF_8) @@ -91,9 +98,13 @@ class HMG_Internet(flutterMainActivity: MainActivity) { jsonObject.getJSONArray("Hmg_SMS_Get_By_ProjectID_And_PatientIDList").let { array -> array.getJSONObject(0).let { object_ -> if (object_.has("UserName") && object_.has("UserName")){ - USER_NAME = object_.getString("UserName") - PASSWORD = object_.getString("Password") - success() + try { + val userName = object_.getString("UserName") + val password = object_.getString("Password") + success(userName, password) + }catch (e:Exception){ + success(null, null) + } }else{ completionOnUiThread(false, "somethingWentWrong") } diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/WpaEnterprise.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/WpaEnterprise.kt index 23871fd6..e8e39344 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/WpaEnterprise.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/hmgwifi/WpaEnterprise.kt @@ -14,6 +14,7 @@ import android.util.Log import androidx.annotation.RequiresApi import com.ejada.hmg.MainActivity import com.ejada.hmg.utils.HMGUtils +import java.security.cert.X509Certificate class WpaEnterprise(private val mainActivity: MainActivity, private var SSID: String) { private var TAG = "WpaEnterprise" @@ -110,8 +111,9 @@ class WpaEnterprise(private val mainActivity: MainActivity, private var SSID: St Log.e(TAG, "connection wifi with Android Q+") val wifiNetworkSpecifier: WifiNetworkSpecifier = WifiNetworkSpecifier.Builder() - .setWpa2EnterpriseConfig(enterpriseConfig()) - .build() + .setSsid(SSID) + .setWpa2EnterpriseConfig(enterpriseConfig()) + .build() val networkRequest: NetworkRequest = NetworkRequest.Builder() .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) @@ -123,6 +125,7 @@ class WpaEnterprise(private val mainActivity: MainActivity, private var SSID: St override fun onAvailable(network: Network) { super.onAvailable(network) connectivityManager.bindProcessToNetwork(network) + completion(true, "200") Log.e(TAG, "onAvailable") } @@ -139,6 +142,7 @@ class WpaEnterprise(private val mainActivity: MainActivity, private var SSID: St override fun onUnavailable() { super.onUnavailable() + completion(false, "401") Log.e(TAG, "onUnavailable") } @@ -154,6 +158,8 @@ class WpaEnterprise(private val mainActivity: MainActivity, private var SSID: St enterpriseConfig.eapMethod = WifiEnterpriseConfig.Eap.PEAP enterpriseConfig.identity = identity enterpriseConfig.password = password + enterpriseConfig.phase2Method = WifiEnterpriseConfig.Phase2.NONE +// enterpriseConfig.caCertificates = WifiEnterpriseConfig.Phase2. return enterpriseConfig; } diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/utils/PlatformBridge.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/utils/PlatformBridge.kt index be127a54..59eaaf90 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/utils/PlatformBridge.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/utils/PlatformBridge.kt @@ -13,11 +13,10 @@ import android.net.wifi.WifiManager import android.util.Log import com.ejada.hmg.MainActivity import com.ejada.hmg.hmgwifi.HMG_Guest -import com.ejada.hmg.hmgwifi.HMG_Internet import com.ejada.hmg.geofence.GeoZoneModel import com.ejada.hmg.geofence.HMG_Geofence +import com.ejada.hmg.hmgwifi.WpaEnterprise import io.flutter.embedding.engine.FlutterEngine -import io.flutter.plugin.common.BinaryMessenger import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel @@ -72,33 +71,53 @@ class PlatformBridge(private var flutterEngine: FlutterEngine, private var mainA private fun connectHMGInternetWifi(methodCall: MethodCall, result: MethodChannel.Result) { (methodCall.arguments as ArrayList<*>).let { - require(it.size > 0 && (it[0] is String), lazyMessage = { - "Missing or invalid arguments (Must have one argument 'String at 0'" + require(it.size == 3 && (it[0] is String) && (it[1] is String), lazyMessage = { + "Missing or invalid arguments (Must have three argument of 'String'" }) - val patientId = it[0].toString() - HMG_Internet(mainActivity) - .connectToHMGGuestNetwork(patientId) { status, message -> + val ssid = it[0].toString() + val username = it[1].toString() + val password = it[2].toString() - mainActivity.runOnUiThread { + WpaEnterprise(mainActivity,ssid).connect(username,password) { status, message -> + HMGUtils.timer(2000,false){ + mainActivity.runOnUiThread { + if(status) result.success(if (status) 1 else 0) - - HMGUtils.popFlutterText(mainActivity, message) - Log.v(this.javaClass.simpleName, "$status | $message") - } - + else + result.error(message, null, null) } + } + } + +// HMG_Internet(mainActivity) +// .connectToHMGGuestNetwork(username, password) { status, message -> +// mainActivity.runOnUiThread { +// result.success(if (status) 1 else 0) +// +// HMGUtils.popFlutterText(mainActivity, message) +// Log.v(this.javaClass.simpleName, "$status | $message") +// } +// +// } } } private fun connectHMGGuestWifi(methodCall: MethodCall, result: MethodChannel.Result) { - HMG_Guest(mainActivity).connectToHMGGuestNetwork { status, message -> - mainActivity.runOnUiThread { - result.success(if (status) 1 else 0) + (methodCall.arguments as ArrayList<*>).let { + require(it.size == 1 && (it[0] is String), lazyMessage = { + "Missing or invalid arguments (Must have one argument 'String at 0'" + }) - HMGUtils.popFlutterText(mainActivity, message) - Log.v(this.javaClass.simpleName, "$status | $message") + val ssid = it[0].toString() + HMG_Guest(mainActivity, ssid).connectToHMGGuestNetwork { status, message -> + mainActivity.runOnUiThread { + result.success(if (status) 1 else 0) + + HMGUtils.popFlutterText(mainActivity, message) + Log.v(this.javaClass.simpleName, "$status | $message") + } } } } diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 3e52d097..33a2b9c6 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -515,6 +515,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = 3A359E86ZF; ENABLE_BITCODE = NO; @@ -535,6 +537,7 @@ MARKETING_VERSION = 4.5.17; PRODUCT_BUNDLE_IDENTIFIER = "com.HMG.HMG-Smartphone"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; @@ -655,6 +658,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = 3A359E86ZF; ENABLE_BITCODE = NO; @@ -675,6 +680,7 @@ MARKETING_VERSION = 4.5.17; PRODUCT_BUNDLE_IDENTIFIER = "com.HMG.HMG-Smartphone"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -689,6 +695,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; DEVELOPMENT_TEAM = 3A359E86ZF; ENABLE_BITCODE = NO; @@ -709,6 +717,7 @@ MARKETING_VERSION = 4.5.17; PRODUCT_BUNDLE_IDENTIFIER = "com.HMG.HMG-Smartphone"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; diff --git a/lib/analytics/flows/app_nav.dart b/lib/analytics/flows/app_nav.dart index 12601fcd..f8a2dbe2 100644 --- a/lib/analytics/flows/app_nav.dart +++ b/lib/analytics/flows/app_nav.dart @@ -10,4 +10,21 @@ class AppNav{ 'nav_name' : value }); } + + log({int tabIndex, bool isLoggedIn}){ + var nav_name = ""; + if(tabIndex == 1) + nav_name = "medical file"; + if(tabIndex == 3) + nav_name = "my family"; + if(tabIndex == 4) + nav_name = "todo list"; + if(tabIndex == 5) + nav_name = "help"; + + if(nav_name.isNotEmpty) + logger(name, parameters: { + 'nav_name' : nav_name + }); + } } \ No newline at end of file diff --git a/lib/analytics/flows/appointments.dart b/lib/analytics/flows/appointments.dart index bd69769d..6c7cb547 100644 --- a/lib/analytics/flows/appointments.dart +++ b/lib/analytics/flows/appointments.dart @@ -74,7 +74,7 @@ class Appointment{ 'treatment_type' : doctor.clinicName, 'doctor_name' : doctor.name, 'doctor_nationality' : doctor.nationalityName, - 'doctor_gender' : doctor.gender, + 'doctor_gender' : doctor.genderDescription, }); } @@ -88,7 +88,7 @@ class Appointment{ 'treatment_type' : doctor.clinicName, 'doctor_name' : doctor.name, 'doctor_nationality' : doctor.nationalityName, - 'doctor_gender' : doctor.gender, + 'doctor_gender' : doctor.genderDescription, }); } @@ -101,7 +101,7 @@ class Appointment{ 'treatment_type' : doctor.clinicName, 'doctor_name' : doctor.name, 'doctor_nationality' : doctor.nationalityName, - 'doctor_gender' : doctor.gender, + 'doctor_gender' : doctor.genderDescription, 'appointment_day' : day }); } @@ -117,7 +117,7 @@ class Appointment{ 'treatment_type' : doctor.clinicName, 'doctor_name' : doctor.name, 'doctor_nationality' : doctor.nationalityName, - 'doctor_gender' : doctor.gender, + 'doctor_gender' : doctor.genderDescription, 'appointment_day' : day, 'appointment_hour' : time }); @@ -134,7 +134,7 @@ class Appointment{ 'treatment_type' : doctor.clinicName, 'doctor_name' : doctor.name, 'doctor_nationality' : doctor.nationalityName, - 'doctor_gender' : doctor.gender, + 'doctor_gender' : doctor.genderDescription, 'appointment_day' : day, 'appointment_hour' : time }); @@ -151,7 +151,7 @@ class Appointment{ 'treatment_type' : doctor.clinicName, 'doctor_name' : doctor.name, 'doctor_nationality' : doctor.nationalityName, - 'doctor_gender' : doctor.gender, + 'doctor_gender' : doctor.genderDescription, 'appointment_day' : day, 'appointment_hour' : time }); @@ -168,7 +168,7 @@ class Appointment{ 'treatment_type' : doctor.clinicName, 'doctor_name' : doctor.name, 'doctor_nationality' : doctor.nationalityName, - 'doctor_gender' : doctor.gender, + 'doctor_gender' : doctor.genderDescription, 'appointment_day' : day, 'appointment_hour' : time }); @@ -200,6 +200,30 @@ class Appointment{ }); } + // R033 + payment_method({@required String appointment_type, clinic, payment_method, payment_type}){ + logger('payment_method', parameters: { + 'appointment_type' : appointment_type, + 'clinic_type' : clinic, + 'payment_method' : payment_method, + 'payment_type' : payment_type + }); + } + + + // R036 + payment_success({@required String appointment_type, clinic, hospital, payment_method, payment_type, txn_number, txn_amount, txn_currency}){ + // appointment_type + // clinic_type_online + // payment_method + // payment_type: 'appointment' + // hospital_name + // transaction_number + // transaction_amount + // transaction_currency + } + + // Note : - Payment flow beyond this step are same as listed under ‘Advance Payment’ section of this document appointment_detail_action({@required AppoitmentAllHistoryResultList appointment, @required String action}){ logger('appointment_detail_action', parameters: { diff --git a/lib/analytics/flows/error_tracking.dart b/lib/analytics/flows/error_tracking.dart index 1ceb2ab9..b42fd114 100644 --- a/lib/analytics/flows/error_tracking.dart +++ b/lib/analytics/flows/error_tracking.dart @@ -5,4 +5,8 @@ class ErrorTracking{ final GALogger logger; ErrorTracking(this.logger); + log({String error}){ + logger(error); + } + } \ No newline at end of file diff --git a/lib/analytics/flows/hmg_services.dart b/lib/analytics/flows/hmg_services.dart index 357f81ab..cd771c1f 100644 --- a/lib/analytics/flows/hmg_services.dart +++ b/lib/analytics/flows/hmg_services.dart @@ -10,4 +10,9 @@ class HMGServices{ 'services_name' : value }); } + viewAll(){ + logger('hmg_services', parameters: { + 'services_name' : 'view all services' + }); + } } \ No newline at end of file diff --git a/lib/analytics/flows/live_care.dart b/lib/analytics/flows/live_care.dart index fd7d03d4..6d2f0c81 100644 --- a/lib/analytics/flows/live_care.dart +++ b/lib/analytics/flows/live_care.dart @@ -40,7 +40,7 @@ class LiveCare{ // R032 livecare_immediate_consultation_TnC({@required String clinic}){ - logger('livecare_immediate_consultation_TnC', parameters: { + logger('livecare_immediate_consultation_tandc', parameters: { 'clinic_type_online' : clinic }); } diff --git a/lib/analytics/flows/login_registration.dart b/lib/analytics/flows/login_registration.dart index cf123b62..4e6a0b3f 100644 --- a/lib/analytics/flows/login_registration.dart +++ b/lib/analytics/flows/login_registration.dart @@ -65,22 +65,38 @@ class LoginRegistration{ }); } + // R011.x + login_verify_otp({@required int method}){ + var verification_method = ''; + if(method == 1) verification_method = 'sms'; + if(method == 2) verification_method = 'fingerprint'; + if(method == 3) verification_method = 'face id'; + if(method == 4) verification_method = 'whatsapp'; + + logger('login_verify_otp', parameters: { + 'login_method' : verification_method + }); + } + // R011.2 forget_file_number(){ logger('forget_file_number'); } // R011.3 - register_now({@required String method}){ - logger('register_now', parameters: { - 'login_method' : method - }); + register_now(){ + logger('register_now'); } // R012.1, R014.1 - login_successful({@required String method}){ + login_successful({@required int method}){ + var verification_method = ''; + if(method == 1) verification_method = 'sms'; + if(method == 2) verification_method = 'fingerprint'; + if(method == 3) verification_method = 'face id'; + if(method == 4) verification_method = 'whatsapp'; logger('login_successful', parameters: { - 'login_method' : method + 'login_method' : verification_method }); } diff --git a/lib/analytics/flows/todo_list.dart b/lib/analytics/flows/todo_list.dart index bfcde052..9a63a26c 100644 --- a/lib/analytics/flows/todo_list.dart +++ b/lib/analytics/flows/todo_list.dart @@ -10,44 +10,44 @@ class TodoList{ // R047.1 to_do_list_pay_now(AppoitmentAllHistoryResultList appointment){ logger('to_do_list_pay_now', parameters: { - 'appointment_type' : appointment.appointmentType, + 'appointment_type' : appointment.isLiveCareAppointment ? 'livecare' : 'regular', 'clinic_type_online' : appointment.clinicName, 'hospital_name' : appointment.projectName, - 'doctor_name' : appointment.doctorName, - 'payment_type' : appointment.patientType, + 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + 'payment_type' : 'appointment', }); } // R047.2 to_do_list_more_details(AppoitmentAllHistoryResultList appointment){ logger('to_do_list_more_details', parameters: { - 'appointment_type' : appointment.appointmentType, + 'appointment_type' : appointment.isLiveCareAppointment ? 'livecare' : 'regular', 'clinic_type_online' : appointment.clinicName, 'hospital_name' : appointment.projectName, - 'doctor_name' : appointment.doctorName, - 'payment_type' : appointment.patientType, + 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + 'payment_type' : 'appointment', }); } // R048 to_do_list_confirm_payment_details(AppoitmentAllHistoryResultList appointment){ logger('to_do_list_confirm_payment_details', parameters: { - 'appointment_type' : appointment.appointmentType, + 'appointment_type' : appointment.isLiveCareAppointment ? 'livecare' : 'regular', 'clinic_type_online' : appointment.clinicName, 'hospital_name' : appointment.projectName, - 'doctor_name' : appointment.doctorName, - 'payment_type' : appointment.patientType, + 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + 'payment_type' : 'appointment', }); } // R048 to_do_list_cancel_payment_details(AppoitmentAllHistoryResultList appointment){ logger('to_do_list_cancel_payment_details', parameters: { - 'appointment_type' : appointment.appointmentType, + 'appointment_type' : appointment.isLiveCareAppointment ? 'livecare' : 'regular', 'clinic_type_online' : appointment.clinicName, 'hospital_name' : appointment.projectName, - 'doctor_name' : appointment.doctorName, - 'payment_type' : appointment.patientType, + 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + 'payment_type' : 'appointment', }); } @@ -57,63 +57,63 @@ class TodoList{ // 'appointment_type' : appointment.appointmentType, // 'clinic_type_online' : appointment.clinicName, // 'hospital_name' : appointment.projectName, - // 'doctor_name' : appointment.doctorName, - // 'payment_type' : appointment.patientType, + // 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + // 'payment_type' : 'appointment', // }); // } // R049.2 to_do_list_cancel_appointment(AppoitmentAllHistoryResultList appointment){ logger('to_do_list_cancel_appointment', parameters: { - 'appointment_type' : appointment.appointmentType, + 'appointment_type' : appointment.isLiveCareAppointment ? 'livecare' : 'regular', 'clinic_type_online' : appointment.clinicName, 'hospital_name' : appointment.projectName, - 'doctor_name' : appointment.doctorName, - 'payment_type' : appointment.patientType, + 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + 'payment_type' : 'appointment', }); } // R049.3 to_do_list_confirm_appointment(AppoitmentAllHistoryResultList appointment){ logger('to_do_list_confirm_appointment', parameters: { - 'appointment_type' : appointment.appointmentType, + 'appointment_type' : appointment.isLiveCareAppointment ? 'livecare' : 'regular', 'clinic_type_online' : appointment.clinicName, 'hospital_name' : appointment.projectName, - 'doctor_name' : appointment.doctorName, - 'payment_type' : appointment.patientType, + 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + 'payment_type' : 'appointment', }); } // R050 to_do_list_check_in(AppoitmentAllHistoryResultList appointment){ logger('to_do_list_check_in', parameters: { - 'appointment_type' : appointment.appointmentType, + 'appointment_type' : appointment.isLiveCareAppointment ? 'livecare' : 'regular', 'clinic_type_online' : appointment.clinicName, 'hospital_name' : appointment.projectName, - 'doctor_name' : appointment.doctorName, - 'payment_type' : appointment.patientType, + 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + 'payment_type' : 'appointment', }); } // R051 to_do_list_nfc(AppoitmentAllHistoryResultList appointment){ logger('to_do_list_nfc', parameters: { - 'appointment_type' : appointment.appointmentType, + 'appointment_type' : appointment.isLiveCareAppointment ? 'livecare' : 'regular', 'clinic_type_online' : appointment.clinicName, 'hospital_name' : appointment.projectName, - 'doctor_name' : appointment.doctorName, - 'payment_type' : appointment.patientType, + 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + 'payment_type' : 'appointment', }); } // R052 to_do_list_nfc_cancel(AppoitmentAllHistoryResultList appointment){ logger('to_do_list_nfc_cancel', parameters: { - 'appointment_type' : appointment.appointmentType, + 'appointment_type' : appointment.isLiveCareAppointment ? 'livecare' : 'regular', 'clinic_type_online' : appointment.clinicName, 'hospital_name' : appointment.projectName, - 'doctor_name' : appointment.doctorName, - 'payment_type' : appointment.patientType, + 'doctor_name' : (appointment.doctorName == null || appointment.doctorName == '') ? appointment.doctorNameObj : appointment.doctorName, + 'payment_type' : 'appointment', }); } } \ No newline at end of file diff --git a/lib/analytics/google-analytics.dart b/lib/analytics/google-analytics.dart index f4142bf5..792175ee 100644 --- a/lib/analytics/google-analytics.dart +++ b/lib/analytics/google-analytics.dart @@ -26,11 +26,21 @@ _logger(String name, {Map parameters}) async { if (name != null && name.isNotEmpty) { if(name.contains(' ')) name = name.replaceAll(' ','_'); + + // To LowerCase + if(parameters != null && parameters.isNotEmpty) + parameters = parameters.map((key, value) { + final key_ = key.toLowerCase(); + var value_ = value; + if(value is String) + value_ = value.toLowerCase(); + return MapEntry(key_, value_); + }); _analytics - .logEvent(name: name.trim(), parameters: parameters) + .logEvent(name: name.trim().toLowerCase(), parameters: parameters) .then((value) { - debugPrint('SUCCESS: Google analytics event "$name" sent'); + debugPrint('SUCCESS: Google analytics event "$name" sent with parameters $parameters'); }).catchError((error) { debugPrint('ERROR: Google analytics event "$name" sent failed'); }); diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 70532e36..2e237660 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -40,7 +40,7 @@ class BaseAppClient { Function(String error, int statusCode) onFailure, bool isAllowAny = false, bool isExternal = false, - bool isRCService = false}) async { + bool isRCService = false, bool bypassConnectionCheck = false}) async { String url; if (isExternal) { url = endPoint; @@ -137,7 +137,7 @@ class BaseAppClient { final jsonBody = json.encode(body); print(jsonBody); - if (await Utils.checkConnection()) { + if (await Utils.checkConnection(bypassConnectionCheck: bypassConnectionCheck)) { final response = await http.post(Uri.parse(url.trim()), body: json.encode(body), headers: headers); final int statusCode = response.statusCode; // print("statusCode :$statusCode"); diff --git a/lib/locator.dart b/lib/locator.dart index df0561fd..ec696865 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/H2O_service.dart'; import 'package:diplomaticquarterapp/core/service/ancillary_orders_service.dart'; +import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart'; import 'package:diplomaticquarterapp/core/service/qr_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart'; @@ -332,4 +333,5 @@ void setupLocator() { // --------------------------- locator.registerFactory(() => GAnalytics()); + locator.registerLazySingleton(() => BaseAppClient()); } diff --git a/lib/pages/BookAppointment/BookSuccess.dart b/lib/pages/BookAppointment/BookSuccess.dart index 15906851..3b0d3ecc 100644 --- a/lib/pages/BookAppointment/BookSuccess.dart +++ b/lib/pages/BookAppointment/BookSuccess.dart @@ -494,12 +494,15 @@ class _BookSuccessState extends State { AppoitmentAllHistoryResultList appo = new AppoitmentAllHistoryResultList(); appo.projectID = widget.patientShareResponse.projectID; appo.clinicID = widget.patientShareResponse.clinicID; + appo.clinicName = widget.patientShareResponse.clinicName; + appo.projectName = widget.patientShareResponse.projectName; appo.appointmentNo = widget.patientShareResponse.appointmentNo; Navigator.push(context, FadePage(page: PaymentMethod(onSelectedMethod: (String metohd) { setState(() {}); }))).then((value) { if (value != null) { + projectViewModel.analytics.appointment.payment_method(appointment_type: 'regular', clinic: widget.docObject.clinicName, payment_method: value, payment_type: 'appointment'); openPayment(value, authUser, double.parse(patientShareResponse.patientShareWithTax.toString()), patientShareResponse, appo); } }); @@ -560,6 +563,10 @@ class _BookSuccessState extends State { service.checkPaymentStatus(Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), context).then((res) { String paymentInfo = res['Response_Message']; if (paymentInfo == 'Success') { + String txn_ref = res['Merchant_Reference']; + String amount = res['Amount']; + String payment_method = res['PaymentMethod']; + projectViewModel.analytics.appointment.payment_success(appointment_type: 'regular', payment_method: payment_method, clinic: appo.clinicName, hospital: appo.projectName, txn_amount: "$amount", txn_currency: 'SAR', txn_number: txn_ref); createAdvancePayment(res, appo); } else { GifLoaderDialogUtils.hideDialog(context); diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index 5e6997bd..5b3c56bd 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -933,7 +933,9 @@ class _ToDoState extends State with SingleTickerProviderStateMixin { print(value); getPatientAppointmentHistory(); - if (value != null) { + if (value != null){ + final appType = appo.isLiveCareAppointment ? 'livecare' : 'regular'; + projectViewModel.analytics.appointment.payment_method(appointment_type: appType, clinic: appo.clinicName, payment_method: value, payment_type: 'appointment'); openPayment(value, projectViewModel.user, double.parse(patientShareResponse.patientShareWithTax.toString()), patientShareResponse, appo); } }); diff --git a/lib/pages/ToDoList/payment_method_select.dart b/lib/pages/ToDoList/payment_method_select.dart index f306fe09..97c6d3ce 100644 --- a/lib/pages/ToDoList/payment_method_select.dart +++ b/lib/pages/ToDoList/payment_method_select.dart @@ -1,5 +1,7 @@ import 'dart:io'; +import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; +import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; diff --git a/lib/pages/ToDoList/widgets/paymentDialog.dart b/lib/pages/ToDoList/widgets/paymentDialog.dart index b145e173..9445e341 100644 --- a/lib/pages/ToDoList/widgets/paymentDialog.dart +++ b/lib/pages/ToDoList/widgets/paymentDialog.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; diff --git a/lib/pages/conference/video-call-web-page.dart b/lib/pages/conference/video-call-web-page.dart new file mode 100644 index 00000000..45a33b3d --- /dev/null +++ b/lib/pages/conference/video-call-web-page.dart @@ -0,0 +1,13 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class VideoCallWebPage extends StatelessWidget{ + + @override + Widget build(BuildContext context) { + return Scaffold( + + ); + } + +} \ No newline at end of file diff --git a/lib/pages/conference/web_rtc/call_home_page_.dart b/lib/pages/conference/web_rtc/call_home_page_.dart index 27fb5919..69161f4c 100644 --- a/lib/pages/conference/web_rtc/call_home_page_.dart +++ b/lib/pages/conference/web_rtc/call_home_page_.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:convert'; import 'package:diplomaticquarterapp/pages/conference/web_rtc/widgets/cam_view_widget.dart'; import 'package:diplomaticquarterapp/pages/conference/widgets/noise_box.dart'; @@ -32,7 +33,7 @@ class _CallHomePageState extends State { //Stream to enable video MediaStream localMediaStream; MediaStream remoteMediaStream; - Signaling signaling = Signaling()..init(); + Signaling signaling = Signaling(); @override void initState() { @@ -44,6 +45,7 @@ class _CallHomePageState extends State { startCall() async{ await _localRenderer.initialize(); await _remoteRenderer.initialize(); + await signaling.init(); final connected = await receivedCall(); } @@ -53,12 +55,29 @@ class _CallHomePageState extends State { localMediaStream = await navigator.mediaDevices.getUserMedia({'video': true, 'audio': true}); _localRenderer.srcObject = localMediaStream; - final connected = await signaling.acceptCall(widget.callerId, widget.receiverId, localMediaStream: localMediaStream, onRemoteMediaStream: (remoteMediaStream){ - setState(() { - this.remoteMediaStream = remoteMediaStream; - _remoteRenderer.srcObject = remoteMediaStream; - }); - }); + final connected = await signaling.acceptCall(widget.callerId, widget.receiverId, localMediaStream: localMediaStream, + onRemoteMediaStream: (remoteMediaStream){ + + // print(remoteMediaStream.toString()); + // print(json.encode(remoteMediaStream.getTracks().asMap())); + this.remoteMediaStream = remoteMediaStream; + _remoteRenderer.srcObject = remoteMediaStream; + _remoteRenderer.addListener(() { + print('_remoteRenderer'); + print(_remoteRenderer); + setState(() {}); + }); + }, + onRemoteTrack: (track){ + _remoteRenderer.srcObject.addTrack(track.track); + // setState(() { + // }); + + print(track.streams.first.getVideoTracks()); + print(track.streams.first.getAudioTracks()); + print(json.encode(track.streams.asMap())); + } + ); if(connected){ signaling.signalR.listen( @@ -88,6 +107,7 @@ class _CallHomePageState extends State { void dispose() { // TODO: implement dispose super.dispose(); + signaling.dispose(); _localRenderer?.dispose(); _remoteRenderer?.dispose(); _audioButton?.close(); diff --git a/lib/pages/landing/fragments/home_page_fragment2.dart b/lib/pages/landing/fragments/home_page_fragment2.dart index 891ea439..1fa298dc 100644 --- a/lib/pages/landing/fragments/home_page_fragment2.dart +++ b/lib/pages/landing/fragments/home_page_fragment2.dart @@ -241,6 +241,7 @@ class _HomePageFragment2State extends State { ), FlatButton( onPressed: () { + projectViewModel.analytics.hmgServices.viewAll(); Navigator.push(context, FadePage(page: AllHabibMedicalSevicePage2())); }, child: Text( diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 1fcc0c24..a12c6419 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -122,6 +122,7 @@ class _LandingPageState extends State with WidgetsBindingObserver { } changeCurrentTab(int tab) { + projectViewModel.analytics.bottomTabNavigation.log(tabIndex: tab, isLoggedIn: projectViewModel.isLogin); if (!projectViewModel.isLogin) { if (tab == 3) { List imagesInfo = []; @@ -137,7 +138,6 @@ class _LandingPageState extends State with WidgetsBindingObserver { imageAr: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/family-file/ar/1.png'), ); - projectViewModel.analytics.bottomTabNavigation.logNavName('my family'); Navigator.push( context, MaterialPageRoute( @@ -157,7 +157,6 @@ class _LandingPageState extends State with WidgetsBindingObserver { imagesInfo.add( ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/todo/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/todo/ar/0.png')); - projectViewModel.analytics.bottomTabNavigation.logNavName('todo list'); Navigator.push( context, MaterialPageRoute( @@ -178,7 +177,6 @@ class _LandingPageState extends State with WidgetsBindingObserver { if (tab == 5) { IS_VOICE_COMMAND_CLOSED = false; triggerRobot(); - projectViewModel.analytics.bottomTabNavigation.logNavName('help robot'); // pageController.jumpToPage(tab); } else { @@ -252,12 +250,10 @@ class _LandingPageState extends State with WidgetsBindingObserver { familyFileProvider.getSharedRecordByStatus(); } }); + // HMG (Guest/Internet) Wifi Access [Zohaib Kambrani] - //for now commented to reduce this call will enable it when needed - // HMGNetworkConnectivity(context, () { - // GifLoaderDialogUtils.showMyDialog(context); - // PlatformBridge.shared().connectHMGGuestWifi().then((value) => {GifLoaderDialogUtils.hideDialog(context)}); - // }).checkAndConnectIfNoInternet(); + // for now commented to reduce this call will enable it when needed + HMGNetworkConnectivity(context).start(); requestPermissions().then((results) { locationUtils.getCurrentLocation(); @@ -484,7 +480,6 @@ class _LandingPageState extends State with WidgetsBindingObserver { physics: NeverScrollableScrollPhysics(), controller: pageController, onPageChanged: (idx){ - projectViewModel.analytics.bottomTabNavigation.logNavName(''); }, children: [ HomePage2( @@ -495,7 +490,6 @@ class _LandingPageState extends State with WidgetsBindingObserver { login(); }, onMedicalFileClick: () { - projectViewModel.analytics.bottomTabNavigation.logNavName('medical file'); changeCurrentTab(1); }, ), diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index b1217409..09dee601 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -273,7 +273,10 @@ class _ConfirmLogin extends State { ), DefaultButton( TranslationBase.of(context).useAnotherAccount, - () => {Navigator.of(context).pushNamed(LOGIN_TYPE)}, + () { + projectViewModel.analytics.loginRegistration.login_with_other_account(); + Navigator.of(context).pushNamed(LOGIN_TYPE); + }, ), ], ), @@ -296,6 +299,7 @@ class _ConfirmLogin extends State { }); } + int login_method = 0; authenticateUser(int type, {int isActive}) { GifLoaderDialogUtils.showMyDialog(context); if (type == 2 || type == 3) { @@ -303,6 +307,7 @@ class _ConfirmLogin extends State { } this.selectedOption = fingrePrintBefore != null ? fingrePrintBefore : type; + login_method = type; switch (type) { case 1: this.loginWithSMS(type); @@ -603,6 +608,7 @@ class _ConfirmLogin extends State { } else { + projectViewModel.analytics.loginRegistration.login_successful(method: login_method), sharedPref.remove(FAMILY_FILE), result.list.isFamily = false, userData = result.list, @@ -622,6 +628,7 @@ class _ConfirmLogin extends State { // Navigator.of(context).pop(), GifLoaderDialogUtils.hideDialog(context), Future.delayed(Duration(seconds: 1), () { + projectViewModel.analytics.errorTracking.log(error: "login_failed: $result"); AppToast.showErrorToast(message: result); startSMSService(tempType); }), @@ -711,7 +718,6 @@ class _ConfirmLogin extends State { Widget _loginOptionButton(String _title, String _icon, int _flag, int _loginIndex) { bool isDisable = (_flag == 3 && !checkIfBiometricAvailable(BiometricType.face) || _flag == 2 && !checkIfBiometricAvailable(BiometricType.fingerprint)); - return InkWell( onTap: isDisable ? null @@ -721,6 +727,7 @@ class _ConfirmLogin extends State { isMoreOption = true; }); } else { + projectViewModel.analytics.loginRegistration.login_verify_otp(method: _flag); authenticateUser(_flag, isActive: _loginIndex); } }, diff --git a/lib/pages/login/login-type.dart b/lib/pages/login/login-type.dart index ab34d75f..af461044 100644 --- a/lib/pages/login/login-type.dart +++ b/lib/pages/login/login-type.dart @@ -1,4 +1,6 @@ +import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/login/forgot-password.dart'; import 'package:diplomaticquarterapp/pages/login/login.dart'; import 'package:diplomaticquarterapp/pages/login/register_new.dart'; @@ -60,7 +62,10 @@ class LoginType extends StatelessWidget { text: TextSpan( text: TranslationBase.of(context).forgotPassword, style: TextStyle(decoration: TextDecoration.underline, fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xffC9272B), letterSpacing: -0.48, height: 18 / 12), - recognizer: TapGestureRecognizer()..onTap = () => Navigator.of(context).push(FadePage(page: ForgotPassword())), + recognizer: TapGestureRecognizer()..onTap = () { + locator().loginRegistration.forget_file_number(); + Navigator.of(context).push(FadePage(page: ForgotPassword())); + }, ), ), ], @@ -71,6 +76,7 @@ class LoginType extends StatelessWidget { width: double.infinity, child: FlatButton( onPressed: () { + locator().loginRegistration.register_now(); Navigator.of(context).push(FadePage(page: RegisterNew())); }, child: Text( @@ -225,9 +231,16 @@ class LoginType extends StatelessWidget { } Widget getButton(BuildContext _context, String _title, String _icon, int _flag) { + var type = ''; + if(_flag == 1) + type = 'national id'; + if(_flag == 2) + type = 'file number'; + return InkWell( onTap: () { LoginType.loginType = _flag; + locator().loginRegistration.login_start(method: type); Navigator.of(_context).push(FadePage(page: Login())); }, child: Container( diff --git a/lib/pages/webRTC/fcm/FCMSendNotification.dart b/lib/pages/webRTC/fcm/FCMSendNotification.dart index f67537cf..08c4cca9 100644 --- a/lib/pages/webRTC/fcm/FCMSendNotification.dart +++ b/lib/pages/webRTC/fcm/FCMSendNotification.dart @@ -73,7 +73,7 @@ class FCM{ }); return success; - // final response = await http.post('https://fcm.googleapis.com/v1/projects/api-project-815750722565/messages:send', headers:headers, body: body); + // final response = await http.post('https://fcm.googleapis.com/v1/projects/api-project-815750722565/messages:send', headers:he aders, body: body); } diff --git a/lib/pages/webRTC/signaling.dart b/lib/pages/webRTC/signaling.dart index a4ba6900..9a4d1c48 100644 --- a/lib/pages/webRTC/signaling.dart +++ b/lib/pages/webRTC/signaling.dart @@ -9,18 +9,82 @@ typedef void RTCIceGatheringStateCallback(RTCIceGatheringState state); typedef void RTCPeerConnectionStateCallback(RTCPeerConnectionState state); typedef void RTCSignalingStateCallback(RTCSignalingState state); +final Map constraints = { + 'mandatory': {}, + 'optional': [ + {'DtlsSrtpKeyAgreement': true}, + ] +}; + +Map snapsis_ice_config = { + 'iceServers': [ + { "urls": 'stun:15.185.116.59:3478' }, + { "urls": "turn:15.185.116.59:3479", "username": "admin", "credential": "admin" }, + ], + // 'sdpSemantics': 'unified-plan' +}; +Map twilio_ice_config = { + "ice_servers": [ + { + "url": "stun:global.stun.twilio.com:3478?transport=udp", + "urls": "stun:global.stun.twilio.com:3478?transport=udp" + }, + { + "url": "turn:global.turn.twilio.com:3478?transport=udp", + "username": "ce8042842b62c21bd20b176f80d6067fd3db81b1e9766312418ef5421d9ca2a2", + "urls": "turn:global.turn.twilio.com:3478?transport=udp", + "credential": "UzGOsiLwPZJ32cjafAebfDDpVrqeQjgpFHZEdau/8r4=" + }, + { + "url": "turn:global.turn.twilio.com:3478?transport=tcp", + "username": "ce8042842b62c21bd20b176f80d6067fd3db81b1e9766312418ef5421d9ca2a2", + "urls": "turn:global.turn.twilio.com:3478?transport=tcp", + "credential": "UzGOsiLwPZJ32cjafAebfDDpVrqeQjgpFHZEdau/8r4=" + }, + { + "url": "turn:global.turn.twilio.com:443?transport=tcp", + "username": "ce8042842b62c21bd20b176f80d6067fd3db81b1e9766312418ef5421d9ca2a2", + "urls": "turn:global.turn.twilio.com:443?transport=tcp", + "credential": "UzGOsiLwPZJ32cjafAebfDDpVrqeQjgpFHZEdau/8r4=" + } + ], + // 'sdpSemantics': 'unified-plan' +}; +Map google_ice_config = { + 'iceServers': [ + { + 'urls': [ + 'stun:stun.l.google.com:19302', + 'stun:stun1.l.google.com:19302', + 'stun:stun2.l.google.com:19302', + 'stun:stun3.l.google.com:19302' + ] + }, + ], + // 'sdpSemantics': 'unified-plan' +}; +Map aws_ice_config = { + 'iceServers': [ + {'url': "stun:ec2-15-185-116-59.me-south-1.compute.amazonaws.com:3478"}, + {'url': "turn:ec2-15-185-116-59.me-south-1.compute.amazonaws.com:3479", 'credential': "admin", 'username': "admin"} + ], + // 'sdpSemantics': 'unified-plan' +}; + class Signaling { dispose() { - if (peerConnection != null) peerConnection.dispose(); + if (peerConnection != null) { + peerConnection.dispose(); + peerConnection.getLocalStreams().forEach((e) => e.dispose()); + peerConnection.getRemoteStreams().forEach((e) => e.dispose()); + } signalR.closeConnection(); } - init() { + init() async{ // Create Peer Connection - createPeerConnection(configuration).then((value) { - peerConnection = value; - registerPeerConnectionListeners(); - }); + peerConnection = await createPeerConnection(google_ice_config, constraints); + registerPeerConnectionListeners(); } initializeSignalR(String userName) async { @@ -78,13 +142,16 @@ class Signaling { // return isCallPlaced; // } - Future acceptCall(String caller, String receiver, {@required MediaStream localMediaStream, @required Function(MediaStream) onRemoteMediaStream}) async { - await initializeSignalR("2001273"); + Future acceptCall(String caller, String receiver, {@required MediaStream localMediaStream, @required Function(MediaStream) onRemoteMediaStream, @required Function(RTCTrackEvent) onRemoteTrack}) async { + await initializeSignalR(receiver); signalR.setContributors(caller: caller, receiver: receiver); await signalR.acceptCall(receiver, caller).catchError((e) => throw 'Failed to inform signalR that i accepted a call'); peerConnection.addStream(localMediaStream); + // peerConnection?.onTrack = (track){ + // onRemoteTrack(track); + // }; peerConnection?.onAddStream = (MediaStream stream) { remoteStream = stream; onRemoteMediaStream?.call(stream); @@ -92,6 +159,7 @@ class Signaling { return true; } + Future declineCall(String caller, String receiver) async { await initializeSignalR(receiver); signalR.setContributors(caller: caller, receiver: receiver); @@ -117,13 +185,23 @@ class Signaling { final receiver = offer['target']; final offerSdp = offer['sdp']; peerConnection.setRemoteDescription(rtcSessionDescriptionFrom(offerSdp)).then((value) { - return peerConnection.createAnswer(); + return peerConnection.createAnswer().catchError((e){ + print(e); + }); }).then((anwser) { - return peerConnection.setLocalDescription(anwser); + return peerConnection.setLocalDescription(anwser).catchError((e){ + print(e); + }); }).then((value) { - return peerConnection.getLocalDescription(); + return peerConnection.getLocalDescription().catchError((e){ + print(e); + }); }).then((answer) { - return signalR.answerOffer(answer, caller, receiver); + return signalR.answerOffer(answer, caller, receiver).catchError((e){ + print(e); + }); + }).catchError((e) { + print(e); }); } @@ -131,42 +209,58 @@ class Signaling { Future createSdpAnswer(String toOfferSdp) async { final offerSdp = rtcSessionDescriptionFrom(jsonDecode(toOfferSdp)); - peerConnection.setRemoteDescription(offerSdp); + peerConnection.setRemoteDescription(offerSdp).catchError((e){ + print(e); + }); - final answer = await peerConnection.createAnswer(); + final answer = await peerConnection.createAnswer().catchError((e){ + print(e); + }); var answerSdp = json.encode(answer); // Send SDP via Push or any channel return answerSdp; } Future createSdpOffer() async { final offer = await peerConnection.createOffer(); - await peerConnection.setLocalDescription(offer); + await peerConnection.setLocalDescription(offer).catchError((e){ + print(e); + }); final map = offer.toMap(); var offerSdp = json.encode(map); // Send SDP via Push or any channel return offerSdp; } addCandidate(String candidateJson) { - peerConnection.addCandidate(rtcIceCandidateFrom(candidateJson)); + peerConnection.addCandidate(rtcIceCandidateFrom(candidateJson)).catchError((e){ + print(e); + }); } void registerPeerConnectionListeners() { + peerConnection.onRenegotiationNeeded = (){ + print('Renegotiation Needed...'); + }; + peerConnection.onIceCandidate = (RTCIceCandidate candidate) { // print(json.encode(candidate.toMap())); - signalR.addIceCandidate(json.encode(candidate.toMap())); + signalR.addIceCandidate(json.encode(candidate.toMap())).catchError((e){ + print(e); + }); }; peerConnection?.onIceGatheringState = (RTCIceGatheringState state) { - // print('ICE gathering state changed: $state'); + print('ICE gathering state changed: $state'); }; peerConnection?.onConnectionState = (RTCPeerConnectionState state) { - // print('Connection state change: $state ${state.index}'); + print('Connection state change: $state'); }; peerConnection?.onSignalingState = (RTCSignalingState state) { - // print('Signaling state change: $state'); + print('Signaling state change: $state'); }; + + } } diff --git a/lib/uitl/HMGNetworkConnectivity.dart b/lib/uitl/HMGNetworkConnectivity.dart index c4044573..2334f89e 100644 --- a/lib/uitl/HMGNetworkConnectivity.dart +++ b/lib/uitl/HMGNetworkConnectivity.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; @@ -17,14 +18,26 @@ import 'package:wifi/wifi.dart'; import 'gif_loader_dialog_utils.dart'; class HMGNetworkConnectivity { + final _platformBridge = PlatformBridge.shared(); final BuildContext context; - final Function callBack; + Function callBack; - final String SSID = "HMG-MobileApp"; + final String GUEST_SSID = "HMG-MobileApp"; + final String PATIENT_SSID = "GUEST-POC"; - HMGNetworkConnectivity(this.context, this.callBack); + HMGNetworkConnectivity(this.context); + + start(){ + checkAndConnectIfNoInternet(); + } void checkAndConnectIfNoInternet() async { + // getMyWifiCredentials((username, password){ + // print(""); + // }); + // + // return; + String pingUrl = "$BASE_URL$PING_SERVICE"; // pingUrl = "https://captive.apple.com"; @@ -32,7 +45,7 @@ class HMGNetworkConnectivity { log(error.toString()); }); - bool alreadyConnected = ssid == SSID; + bool alreadyConnected = ssid == GUEST_SSID; BaseAppClient().simpleGet(pingUrl, onSuccess: (dynamic response, int statusCode) { log("Having internet with status code: $statusCode"); @@ -40,12 +53,12 @@ class HMGNetworkConnectivity { if (alreadyConnected) showFailDailog(TranslationBase.of(context).failedToAccessHmgServices); else { - confirmFromUser(); + confirmFromUser(connectForLocalAccess); } }); } - void confirmFromUser() { + void confirmFromUser(VoidCallback confirmCallback) { TranslationBase translator = TranslationBase.of(context); void doIt() { @@ -54,8 +67,8 @@ class HMGNetworkConnectivity { confirmMessage: translator.wantToConnectWithHmgNetwork, okText: translator.yes, okFunction: () { - ConfirmDialog.closeAlertDialog(context); - callBack(); + // ConfirmDialog.closeAlertDialog(context); + confirmCallback(); }, cancelText: translator.no, cancelFunction: () { @@ -64,8 +77,8 @@ class HMGNetworkConnectivity { } if (Platform.isAndroid) - Wifi.list(SSID).then((value) { - if (!value.indexWhere((element) => element.ssid == SSID).isNegative) doIt(); + Wifi.list(GUEST_SSID).then((value) { + if (!value.indexWhere((element) => element.ssid == GUEST_SSID).isNegative) doIt(); }); else doIt(); @@ -82,6 +95,40 @@ class HMGNetworkConnectivity { }).showAlertDialog(context); } + + connectForLocalAccess(){ + GifLoaderDialogUtils.showMyDialog(context); + _platformBridge.connectHMGGuestWifi(GUEST_SSID).then((value) async{ + if(value == 0){ + GifLoaderDialogUtils.hideDialog(context); + }else{ + getPatientWifiCredentials((username, password) async{ + final result = await _platformBridge.connectHMGInternetWifi(PATIENT_SSID, username, password).catchError((err) => print(err.toString())); + GifLoaderDialogUtils.hideDialog(context); + if(result == 1){ + // Success + } + }); + } + }); + } + + getPatientWifiCredentials(Function(String username, String password) successCallback){ + final body = {"PatientID" : "1231755"}; + locator().post(WIFI_CREDENTIALS, body:body, onSuccess: (dynamic response, int statusCode){ + print(response); + var data = response["Hmg_SMS_Get_By_ProjectID_And_PatientIDList"]; + if(data is List && data.first != null){ + final username = data.first['UserName']; + final password = data.first['Password']; + if(username != null && password != null && username.isNotEmpty && password.isNotEmpty){ + successCallback(username, password); + } + } + }, onFailure: (String error, int statusCode){ + print(error); + }, bypassConnectionCheck: true); + } // void next() { // if (Platform.isIOS) { // confirmFromUser_iOS(); diff --git a/lib/uitl/PlatformBridge.dart b/lib/uitl/PlatformBridge.dart index 45970e5e..3efeba9e 100644 --- a/lib/uitl/PlatformBridge.dart +++ b/lib/uitl/PlatformBridge.dart @@ -92,18 +92,18 @@ class PlatformBridge { static const ASK_DRAW_OVER_APPS_PERMISSION = "askDrawOverAppsPermission"; static const GET_INTENT = "getIntent"; - Future connectHMGInternetWifi(String patientId) { + Future connectHMGInternetWifi(String ssid, username, password) { try { - return platform.invokeMethod(hmg_internet_wifi_connect_method, [patientId]); + return platform.invokeMethod(hmg_internet_wifi_connect_method, [ssid, username,password]); } on PlatformException catch (e) { print(e); return Future.error(e); } } - Future connectHMGGuestWifi() { + Future connectHMGGuestWifi(String ssid) { try { - return platform.invokeMethod(hmg_guest_wifi_connect_method); + return platform.invokeMethod(hmg_guest_wifi_connect_method, ssid); } on PlatformException catch (e) { print(e); return Future.error(e); diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index c31df2ad..aed0f47f 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -68,7 +68,10 @@ class Utils { } /// Check The Internet Connection - static Future checkConnection() async { + static Future checkConnection({bool bypassConnectionCheck = false}) async { + if(bypassConnectionCheck) + return true; + ConnectivityResult connectivityResult = await (Connectivity().checkConnectivity()); if ((connectivityResult == ConnectivityResult.mobile) || (connectivityResult == ConnectivityResult.wifi)) { return true; @@ -498,9 +501,9 @@ class Utils { if (projectViewModel.isLogin && userData_ != null || true) { String patientID = userData_.patientID.toString(); GifLoaderDialogUtils.showMyDialog(context); - projectViewModel.platformBridge().connectHMGInternetWifi(patientID).then((value) => {GifLoaderDialogUtils.hideDialog(context)}).catchError((err) { - print(err.toString()); - }); + // projectViewModel.platformBridge().connectHMGInternetWifi(patientID).then((value) => {GifLoaderDialogUtils.hideDialog(context)}).catchError((err) { + // print(err.toString()); + // }); } else { AlertDialogBox( context: context, diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 6348edfc..5375e97d 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -1,4 +1,3 @@ -import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:diplomaticquarterapp/analytics/google-analytics.dart'; import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; @@ -21,10 +20,10 @@ import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart'; -import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart'; import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/theme/theme_notifier.dart'; import 'package:diplomaticquarterapp/theme/theme_value.dart'; +import 'package:diplomaticquarterapp/uitl/HMGNetworkConnectivity.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; @@ -195,23 +194,11 @@ class _AppDrawerState extends State { Navigator.of(context).pushNamed( MY_FAMILIY, ); + locator().hamburgerMenu.logMenuItemClick('my family'); }, ) : SizedBox(), - InkWell( - child: DrawerItem(TranslationBase.of(context).pharmacyLiveCare, SvgPicture.asset("assets/images/new/Live_Care.svg"), - isImageIcon: true, - bottomLine: false, - textColor: Theme.of(context).textTheme.bodyText1.color, - iconColor: Theme.of(context).textTheme.bodyText1.color, - sideArrow: true, - letterSpacing: -0.84, - projectProvider: projectProvider), - onTap: () { - readQRCode(); - }, - ), FutureBuilder( future: getFamilyFiles(), // async work builder: (BuildContext context, AsyncSnapshot snapshot) { @@ -413,7 +400,6 @@ class _AppDrawerState extends State { child: DrawerItem(TranslationBase.of(context).logout, SvgPicture.asset("assets/images/new/logout.svg"), isImageIcon: true, bottomLine: false, letterSpacing: -0.84, fontSize: 14, projectProvider: projectProvider), onTap: () { - locator().hamburgerMenu.logMenuItemClick('logout'); logout(); }, ) @@ -446,11 +432,8 @@ class _AppDrawerState extends State { onTap: () { Navigator.push(context, FadePage(page: CallPage())); locator().hamburgerMenu.logMenuItemClick('cloud solution logo tap'); - String patientID = '2001273'; GifLoaderDialogUtils.showMyDialog(context); - projectProvider.platformBridge().connectHMGInternetWifi(patientID).then((value) => {GifLoaderDialogUtils.hideDialog(context)}).catchError((err) { - print(err.toString()); - }); + HMGNetworkConnectivity(context).start(); }, child: Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -526,12 +509,14 @@ class _AppDrawerState extends State { await sharedPref.remove(APPOINTMENT_HISTORY_MEDICAL); this.user = null; Navigator.of(context).pushNamed(HOME); + locator().hamburgerMenu.logMenuItemClick('logout'); }, cancelFunction: () => {}); dialog.showAlertDialog(context); } login() async { + locator().hamburgerMenu.logMenuItemClick('login'); var data = await sharedPref.getObject(IMEI_USER_DATA); sharedPref.remove(REGISTER_DATA_FOR_LOGIIN); @@ -645,19 +630,8 @@ class _AppDrawerState extends State { }) .catchError((err) { print(err); - }); - } - - readQRCode() async { - String result = (await BarcodeScanner.scan())?.rawContent; - print(result); - GifLoaderDialogUtils.showMyDialog(context); - LiveCareService service = new LiveCareService(); - service.getPatientInfoByQR(result, context).then((res) { - GifLoaderDialogUtils.hideDialog(context); - }).catchError((err) { - GifLoaderDialogUtils.hideDialog(context); - print(err); + //Utils.hideProgressDialog(); + // GifLoaderDialogUtils.hideDialog(context); }); } diff --git a/lib/widgets/in_app_browser/InAppBrowser.dart b/lib/widgets/in_app_browser/InAppBrowser.dart index 39c620d5..960b6224 100644 --- a/lib/widgets/in_app_browser/InAppBrowser.dart +++ b/lib/widgets/in_app_browser/InAppBrowser.dart @@ -32,6 +32,7 @@ class MyInAppBrowser extends InAppBrowser { static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWeb/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/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE static String PREAUTH_SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort PreAuth Payment Gateway URL UAT