Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] UnityAds does not load with Mediation #1792

Closed
5 of 29 tasks
wasedaigo opened this issue Dec 25, 2018 · 12 comments · Fixed by #4921
Closed
5 of 29 tasks

[Android] UnityAds does not load with Mediation #1792

wasedaigo opened this issue Dec 25, 2018 · 12 comments · Fixed by #4921

Comments

@wasedaigo
Copy link
Contributor

wasedaigo commented Dec 25, 2018

🔥🔥🔥

Issue

RewardedVideo of UnityAds does not show up on Android with Admob Mediation

I found the following warning

UnityAdapter: Context is not an Activity. 
Unity Ads requires an Activity context to load ads.

Changing getContext() into getActivity() fixed the problem, however I do not know if this is the right solution. (I modified the following line)
https://github.com/invertase/react-native-firebase/blob/master/android/src/main/java/io/invertase/firebase/admob/RNFirebaseAdMobRewardedVideo.java#L28

I assume other mediation adapters such as adcolony, appodeal also have the same issue, as I read somewhere they also need activity context.

Project Files

Android

iOS

Environment

  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • If known, the version of the platform are you experiencing the issue on:
    • Android API 21
  • Operating System:
    • MacOS, version: N/A
    • Windows, version: N/A
    • Other, please specify: N/A
  • Build Tools:
    • Android Studio 3.2
  • **React Native
    • version:0.57.4
  • **React Native Firebase
    • library version:5.1.0
  • Firebase module(s) you're using that has the issue:
    • N/A
    • Authentication
    • Analytics
    • Cloud Firestore
    • Cloud Messaging (FCM)
    • Crashlytics
    • Dynamic Links
    • Functions Callable
    • Invites
    • Instance ID
    • Notifications
    • Performance Monitoring
    • Realtime Database
    • Remote Config
    • Storage
  • Are you using TypeScript?
    • No
    • Yes, version: N/A
  • Are you using Expo, e.g. ExpoKit?
    • No
    • Yes, I've not ejected
    • Yes, but I have ejected to ExpoKit
    • Yes, but I have ejected to vanilla React Native
    • Expo version: N/A
@stale
Copy link

stale bot commented Feb 10, 2019

Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Type: Stale Issue has become stale - automatically added by Stale bot label Feb 10, 2019
@wasedaigo
Copy link
Contributor Author

No Mr. bot, I made a PR ...
#1892

@stale stale bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label Feb 10, 2019
@Salakar Salakar added the Keep Open avoids the stale bot label Feb 10, 2019
@Salakar
Copy link
Member

Salakar commented Feb 10, 2019

Pinned it 🙈 thanks again for the PR, will take a look once CI is back to normal

@wasedaigo
Copy link
Contributor Author

@Salakar Thank you very much!

@mikehardy
Copy link
Collaborator

haha - I think we fixed this one!

@mikehardy mikehardy removed the Keep Open avoids the stale bot label Jun 16, 2019
@tarouboy
Copy link

Hi @wasedaigo
it happens on v10.3 again.
Failed to load ad: 105: Unity Ads requires an Activity context to load ads.

Do you know how to fix it? 🆘 🙏

@wasedaigo
Copy link
Contributor Author

I am not using ReactNative anymore so... I don't know!
Maybe refer to this PR and see what is missing in the current codebase?

https://github.com/invertase/react-native-firebase/pull/1892/files

@zyzo
Copy link
Contributor

zyzo commented Feb 15, 2021

Anyone found out how to fix this ? I'm using the latest version of @react-native-firebase/admob and I'm seeing this issue (only for Android):

package.json

  "@react-native-firebase/admob": "^10.7.0",
  "@react-native-firebase/app": "^10.7.0",
  "react-native": "0.63.2",

app/build.gradle

 implementation 'com.google.android.gms:play-services-ads:19.6.0'
 implementation 'com.google.ads.mediation:unity:3.6.0.0'

@zyzo
Copy link
Contributor

zyzo commented Feb 16, 2021

I was able to display Unity ads with this fix
BetOnYou@260ceee

@mikehardy
Copy link
Collaborator

@zyzo if that's something we need to change, I would happily collaborate to merge a PR if you posted one. One thing to pay attention to in react-native is that it is possible at any time that the Activity context is unexpectedly null when you ask for it, because the Activity react-native uses can go away before the native request has asynchronously been passed down to native and started executing. But if you just carefully check for null when request the activity context and have a reasonable fallback (and maybe a native info log message for developers so they know what happened when the ad failed to load rarely) then it could be an easy PR

@tarouboy
Copy link

@zyzo if that's something we need to change, I would happily collaborate to merge a PR if you posted one. One thing to pay attention to in react-native is that it is possible at any time that the Activity context is unexpectedly null when you ask for it, because the Activity react-native uses can go away before the native request has asynchronously been passed down to native and started executing. But if you just carefully check for null when request the activity context and have a reasonable fallback (and maybe a native info log message for developers so they know what happened when the ad failed to load rarely) then it could be an easy PR

However without the Activity context it won't even load.
Failed to load ad: 105: Unity Ads requires an Activity context to load ads.

I was able to display Unity ads with this fix
BetOnYou@260ceee

It also applies on Interstitial Ads

@mikehardy
Copy link
Collaborator

fix Releasing as 10.8.1 right now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants