Skip to content

Commit

Permalink
fix: add FragmentActivity check and error handling in RNPaywallsModule (
Browse files Browse the repository at this point in the history
  • Loading branch information
NosimusAI committed Feb 22, 2025
1 parent 23db42a commit 57d14fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ internal class PaywallViewManager : BasePaywallViewManager<PaywallView>() {
}

override fun createViewInstance(themedReactContext: ThemedReactContext): PaywallView {
return PaywallView(themedReactContext).also { view ->
view.setPaywallListener(createPaywallListenerWrapper(themedReactContext, view))
view.setDismissHandler(getDismissHandler(themedReactContext, view))
return PaywallView(themedReactContext).apply {
// Ensure the view is properly initialized before setting listeners
post {
setPaywallListener(createPaywallListenerWrapper(themedReactContext, this))
setDismissHandler(getDismissHandler(themedReactContext, this))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal class RNPaywallsModule(reactContext: ReactApplicationContext) :
is FragmentActivity -> currentActivity
else -> {
Log.e(NAME, "RevenueCat paywalls require application to use a FragmentActivity")
promise.reject("E_ACTIVITY_NOT_FRAGMENT", "Current activity is not a FragmentActivity")
null
}
}
Expand Down

0 comments on commit 57d14fb

Please sign in to comment.