I'm trying to purchase a packages using the Revenue Cat SDK under JetPack Compose.
The SDK provides a function called PurchasePackage()
(and PurchasePackageWith()
) but all of these function's signatures require an Activity
which I do not know how to obtain from an @Composable
.
I've tried this answer from S.O. https://stackoverflow.com/a/68423182/695524 but that gives my null
as the Activity.
What does work is: val activity = LocalContext.current as Activity
but, according to this answer: https://stackoverflow.com/a/65243835/695524 that is potentially unsafe to user in production code.
So, how to safely obtain an Activity
from Jetpack compose so I can Purchase a Package using the Revenue Cat SDK?