Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

How to handle airplane mode / no internet available? #44

Closed
scottc5 opened this issue Nov 4, 2021 · 2 comments · Fixed by #46
Closed

How to handle airplane mode / no internet available? #44

scottc5 opened this issue Nov 4, 2021 · 2 comments · Fixed by #46

Comments

@scottc5
Copy link

scottc5 commented Nov 4, 2021

Does anyone have a way to handle airplane mode or no connection available when using this library. Right now for example, my hook line is giving me unhandled promise rejection -> Error while connecting to ad server, when I cant connect to the internet and try to load this line: const { adLoadError, adLoaded, show, load, reward, adPresented, adDismissed } = useRewardedAd(TestIds.REWARDED );

I am not well versed with hooks and I'm not really sure how to go about resolving this or if I should take a different approach? Thanks.

@wjaykim
Copy link
Collaborator

wjaykim commented Nov 4, 2021

Hi, when error loads fail because internet is not available, adLoadError will be set. You can handle it by checking adLoadError is not undefined. Also, more preferred way is showing ad only if ad is loaded, using adLoaded value. If adLoaded value is true, show your ad, otherwise, just move to next screen.

Corresponding example can be found in Documentation.

Also, I found internal code does not handle promise rejection on the very first load if the ad is loaded automatically thus throws the warning. You can ignore the warning this time. I'll update code to remove the warning in the next version.

@scottc5
Copy link
Author

scottc5 commented Nov 5, 2021

Awesome thanks for your response and explanation! Also thanks for looking into the warning!

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

Successfully merging a pull request may close this issue.

2 participants