proyecto26 / react-native-inappbrowser

📱InAppBrowser for React Native (Android & iOS) 🤘
https://www.npmjs.com/package/react-native-inappbrowser-reborn
MIT License
1.3k stars 223 forks source link

Hide Share icon is not working on android #461

Closed hrishiakhade closed 1 month ago

hrishiakhade commented 1 month ago

Hello , I'm struggling with hiding the share icon on android. enableDefaultShare: false is not working on Android. Has anyone faced this issue? Also, any idea how to remove the arrow-down icon on the right side of the Close icon?

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Build.gradle

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 21
        compileSdkVersion = 34
        targetSdkVersion = 34
        ndkVersion = "25.1.8937393"
        kotlinVersion = "1.8.0"
        androidXAnnotation = "1.2.0"
        androidXBrowser = "1.3.0"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
    }
}

apply plugin: "com.facebook.react.rootproject"

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.

Is there any code involved?

  const openLink = async () => {
    try {
      const isAvailable = await InAppBrowser?.isAvailable();
      if (isAvailable) {
        console.log("url....", url);

        console.log("Before openingng  InAppBrowser....");

        const result = await InAppBrowser.open(url, {
          // iOS Properties
          dismissButtonStyle: 'cancel',
          preferredBarTintColor: '#453AA4',
          preferredControlTintColor: 'white',
          readerMode: false,
          modalPresentationStyle: 'fullScreen',
          modalTransitionStyle: 'coverVertical',
          modalEnabled: true,
          enableBarCollapsing: true,
          // Android Properties
          showTitle: true,
          toolbarColor: '#6200EE',
          secondaryToolbarColor: 'black',
          navigationBarColor: 'black',
          navigationBarDividerColor: 'white',
          enableUrlBarHiding: true,
          enableDefaultShare: false,

          forceCloseOnRedirection: false,
          showInRecents: true,

        })

        setShowIndicator(false);

        console.log("result....", result);

        if (result.type === 'cancel') {
          navigation.reset({
            index: 0,
            routes: [{ name: 'Home' }],
          });
        }
        else if (result.type === 'dismiss') {
          openLink();
        }
      }
      else {
        Alert.alert('InAppBrowser is not available')
      }
    } catch (error) {
      Alert.alert(error.message)
    }
  }

  useEffect(() => {
    InAppBrowser.mayLaunchUrl(url, []);
    openLink();
  }, []);

secure

hrishiakhade commented 1 month ago

Replaced the native library code

from

    if (options.hasKey(KEY_DEFAULT_SHARE_MENU_ITEM) && 
        options.getBoolean(KEY_DEFAULT_SHARE_MENU_ITEM)) {
      builder.addDefaultShareMenuItem();
    }

to

    if(options.hasKey(KEY_DEFAULT_SHARE_MENU_ITEM)){
      if(options.getBoolean(KEY_DEFAULT_SHARE_MENU_ITEM)){
        builder.setShareState(CustomTabsIntent.SHARE_STATE_ON);
      }else{
        builder.setShareState(CustomTabsIntent.SHARE_STATE_OFF);
      }
    }else{
      builder.setShareState(CustomTabsIntent.SHARE_STATE_OFF);
    }