Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(mobile): keep Android connections alive in the background #5179

Closedsnipemanmike(GitHub profile, opens in a new tab)wants to merge 12 commits intomain fromrefs/pull/5179/headopened View on GitHub

Showing 59 changed files with 146 additions and 0 deletions (loading 56).

x
0 of 59 viewed, 59 left
107 additions and 0 deletionsapps/mobile/modules/t3-background-connection/android/src/main/java/expo/modules/t3backgroundconnection/T3BackgroundConnectionModule.ktAdded
View file
@@ -0,0 +1,107 @@
+package expo.modules.t3backgroundconnection
+​
+import android.content.Context
+import android.content.Intent
+import android.net.Uri
+import android.os.Build
+import android.provider.Settings
+import expo.modules.kotlin.functions.Queues
+import expo.modules.kotlin.modules.Module
+import expo.modules.kotlin.modules.ModuleDefinition
+​
+class T3BackgroundConnectionModule : Module() {
+ private val statusListener: (Map<String, Any>) -> Unit = { status ->
+ sendEvent(T3BackgroundConnectionState.STATUS_EVENT, status)
+ }
+ private val stopRequestListener: () -> Unit = {
+ sendEvent(T3BackgroundConnectionState.STOP_REQUEST_EVENT)
+ }
+​
+ override fun definition() = ModuleDefinition {
+ Name("T3BackgroundConnection")
+​
+ Events(
+ T3BackgroundConnectionState.STATUS_EVENT,
+ T3BackgroundConnectionState.STOP_REQUEST_EVENT,
+ )
+​
+ OnCreate {
+ val context = applicationContext()
+ T3BackgroundConnectionState.initialize(context)