Skip to content

Commit

Permalink
docs: add note about maybe-dangerous use of currentActivity
Browse files Browse the repository at this point in the history
Hopefully no one will ever read it or care!
But if there are crashes, our current understanding and reasoning is now noted for future maintainer use
  • Loading branch information
mikehardy authored Dec 2, 2024
1 parent 1a1a778 commit 43a6b2e
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ class ReactNativeGoogleMobileAdsModule(
@ReactMethod
fun initialize(promise: Promise) {
MobileAds.initialize(
// in react-native, the Activity instance *may* go away, becoming null after initialize
// it is not clear if that can happen here without an initialize necessarily following the Activity lifecycle
// it is not clear if that will cause problems even if it happens, but users that have widely deployed this
// with the use of currentActivity have not seen problems
// reference if it needs attention: https://github.com/invertase/react-native-google-mobile-ads/pull/664
currentActivity ?: reactApplicationContext,
OnInitializationCompleteListener { initializationStatus ->
val result = Arguments.createArray()
Expand Down

0 comments on commit 43a6b2e

Please sign in to comment.