callstack / react-native-fbads

Facebook Audience SDK integration for React Native
MIT License
438 stars 142 forks source link

After the video interstitial is closed, there is a new space at the bottom of the KeyboardAvoidingView. #291

Open JoonDong2 opened 3 years ago

JoonDong2 commented 3 years ago

Bug Report

Before opening

Ad Modules video interstitial

Platforms iOS

Versions 14.4.2

Ads Environment

Current Behaviour If there is a KeyboardAvoidingView component on the screen, after the video interstitial is closed and the keyboard appears, a new space is created. Interstitial ads without video do not.

I tested on react native 0.63.4 and 0.64.0. and I am using latest version of this libaray.

TMaszko commented 3 years ago

Could you please share a repo where we can easily reproduce this bug ? Thanks in advance :)

JoonDong2 commented 3 years ago

Could you please share a repo where we can easily reproduce this bug ? Thanks in advance :)

When the video interstitial is executed and closed, the height value of the status bar in iOS becomes 0.

So, because of this, when the keyboard appears in the KeyboardAvoidingView, there is an empty space as much as the status bar below.

I am temporarily managing keyboardVerticalOffset as a state.

import { NativeModules } from "react-native";
const { StatusBarManager } = NativeModules;

useEffect(() => {
    StatusBarManager.getHeight((statusBarFrameData: any) => {
        console.log(statusBarFrameData.height) // => initial value is 20 on iPhone 6S.
    });
    return () => {}
}, [])

const preloadInterstitialAd = async () => {
    const didClick = await InterstitialAdManager.preloadAd(FacebookAdsPlacementIds['interstitial']);
    if(isIOS) {
        StatusBarManager.getHeight((statusBarFrameData: any) => {
            setKeyboardVerticalOffset(statusBarFrameData.height) // => changed to 0.
        });
    }
    if(didClick) {
        // ...
    }
}

// getStatusBarHeight() returns 20 on iPhone 6S.
return (
    <KeyboardAvoidingView
            enabled 
            behavior={isAndroid ? 'height' : 'padding'}
            keyboardVerticalOffset={getStatusBarHeight()}>
    ...
    </<KeyboardAvoidingView>
)