diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3361d03..9315b84 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -15,6 +15,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.SuperApp" + android:usesCleartextTraffic="true" tools:targetApi="31"> () - timeContext["startingRoute"] = "/time" PortalManager.newPortal("time") .setStartDir("time-tracking") - .setInitialContext(timeContext) .create() // Human Resources Portal - val hrContext = HashMap() - hrContext["startingRoute"] = "/hr" PortalManager.newPortal("hr") .setStartDir("human-resources") - .setInitialContext(hrContext) .create() // People Perks Portal - val perksContext = HashMap() - perksContext["startingRoute"] = "/perks" PortalManager.newPortal("perks") .setStartDir("perks") - .setInitialContext(perksContext) .create() // CRM Portal - val crmContext = HashMap() - perksContext["startingRoute"] = "/crm" PortalManager.newPortal("crm") .setStartDir("crm") - .setInitialContext(crmContext) .create() } } \ No newline at end of file diff --git a/android/app/src/main/java/io/ionic/superapp/data/DataManager.kt b/android/app/src/main/java/io/ionic/superapp/data/DataManager.kt index e97f0eb..b092b07 100644 --- a/android/app/src/main/java/io/ionic/superapp/data/DataManager.kt +++ b/android/app/src/main/java/io/ionic/superapp/data/DataManager.kt @@ -17,6 +17,7 @@ import io.ionic.superapp.data.model.App import io.ionic.superapp.data.model.Employee import io.ionic.superapp.data.model.Event import io.ionic.superapp.data.model.News +import org.json.JSONObject import java.lang.Exception class DataManager { @@ -81,14 +82,15 @@ class DataManager { return listOf(timeApp, hrApp, perksApp) } - fun getSessionObject(): HashMap { - val sessionMap = HashMap() + fun getSessionObject(): JSONObject { + val supabaseObject = JSONObject() session?.let { - sessionMap["refreshToken"] = it.refreshToken - sessionMap["accessToken"] = it.accessToken + supabaseObject.put("url","http://10.0.2.2:54321") + supabaseObject.put("refreshToken", it.refreshToken) + supabaseObject.put("accessToken", it.accessToken) } - return sessionMap + return supabaseObject } suspend fun logout() { diff --git a/android/app/src/main/java/io/ionic/superapp/ui/app/AppActivity.kt b/android/app/src/main/java/io/ionic/superapp/ui/app/AppActivity.kt index 5bb07b9..ebefdb4 100644 --- a/android/app/src/main/java/io/ionic/superapp/ui/app/AppActivity.kt +++ b/android/app/src/main/java/io/ionic/superapp/ui/app/AppActivity.kt @@ -9,7 +9,8 @@ import io.ionic.portals.PortalFragment import io.ionic.portals.PortalManager import io.ionic.superapp.R import io.ionic.superapp.data.DataManager -import java.util.HashMap +import io.ionic.superapp.ui.plugins.DismissPlugin +import org.json.JSONObject class AppActivity : AppCompatActivity() { @@ -24,14 +25,17 @@ class AppActivity : AppCompatActivity() { val portal: Portal = PortalManager.getPortal(portalName) val portalFragment = PortalFragment(portal) - val initialContext = portal.initialContext as HashMap - initialContext.putAll(DataManager.instance.getSessionObject()) + portal.addPluginInstance(DismissPlugin { finish() }) + + val initialContext = JSONObject() + initialContext.put("supabase", DataManager.instance.getSessionObject()) if(!eventId.isNullOrEmpty()) { - initialContext["eventId"] = eventId - portalFragment.setInitialContext(initialContext) + initialContext.put("eventId", eventId) } + portalFragment.setInitialContext(initialContext.toString()) + val fragmentManager: FragmentManager = supportFragmentManager fragmentManager.beginTransaction().replace(R.id.portalFrame, portalFragment).commit() } else { diff --git a/android/app/src/main/java/io/ionic/superapp/ui/plugins/DismissPlugin.kt b/android/app/src/main/java/io/ionic/superapp/ui/plugins/DismissPlugin.kt new file mode 100644 index 0000000..ecbf199 --- /dev/null +++ b/android/app/src/main/java/io/ionic/superapp/ui/plugins/DismissPlugin.kt @@ -0,0 +1,16 @@ +package io.ionic.superapp.ui.plugins + +import com.getcapacitor.Plugin +import com.getcapacitor.PluginCall +import com.getcapacitor.PluginMethod +import com.getcapacitor.annotation.CapacitorPlugin + +@CapacitorPlugin(name = "Dismiss") +class DismissPlugin(val callback: () -> Unit) : Plugin() { + + @PluginMethod + fun dismiss(call: PluginCall) { + callback() + call.resolve() + } +} \ No newline at end of file