Justin Xu
04/28/2023, 8:15 AMActivityResultLauncher to get the google account token and pass it to a callback in my ViewModel to authenticate. From my understanding however, ActivityResultLaunchers (and their callbacks) must be declared in Activity's onCreate before Compose's setContent. At the same time though, any ViewModels managed by Voyager must be created in a Screen (as outlined in their docs) , which is called inside setContent similar to a Composable. So my ViewModel callback must be present when the launcher is created before setContent, but is also only available inside setContent using Voyager. Is there a clean way around this?Justin Xu
04/28/2023, 8:19 AMSrSouza
04/28/2023, 1:16 PMrememberLauncherForActivityResult ?Ian Lake
04/28/2023, 1:59 PMJustin Xu
04/28/2023, 6:43 PMJustin Xu
04/29/2023, 10:19 AMGoogleSignInClient - Must be created in an Activity, provides sign in intent to
2. ManagedActivityResultLauncher - Launcher for Google sign in activity
3. Sign in ViewModel function - My custom authentication in using google account token, launcher should provide Google account token to this function in launcher callback
2 can be available in Activity and Composables using rememberLauncherForActivityResult , but 1 is only available in Android activity, and 3 is only available in shared composables since that's where the Voyager ScreenModels are created. The only solutions I can think of is
a. provide 1 to 3, but that would mean passing an Android dependency into my common Composables
b. provide 3 to 1 by creating my ViewModel in the Activity, but that would go against Voyager's VM management inside Composables
Not sure if there is a clean way around this