MaxAst / expo-share-extension

Expo config plugin for creating iOS share extensions with a custom view.
MIT License
247 stars 8 forks source link

[BUG] openHostApp doesn't work on any version IOS #59

Open kauan777 opened 8 hours ago

kauan777 commented 8 hours ago

Info:

"expo": "~51.0.38",
"expo-share-extension": "^1.10.5",
"react-native": "0.74.5",

IOS: 18.1, i has tried ios 17.5 too

ShareExtension.tsx

import { close, openHostApp } from "expo-share-extension";
import { Text, View, TouchableOpacity } from "react-native";
import Svg from "react-native-svg";
import { Path } from "react-native-svg-charts";

export default function ShareExtension({ url }: { url: string }) {
  const handleOpenHostApp = () => {
    openHostApp(`/tab?url=${url}`);
  };

  return (
    <View className="flex-1 justify-center items-center">
      <View className="justify-center items-end w-full absolute top-5 right-5">
        <TouchableOpacity onPress={close}>
          <CloseIcon />
        </TouchableOpacity>
      </View>
      <TouchableOpacity onPress={handleOpenHostApp} className="items-center justify-center">
        <Text className="text-white font-black-poppins text-center text-lg">Open with 2</Text>
      </TouchableOpacity>
    </View>
  );
}

index.js

import App from "./App";
import { Text, TextInput } from "react-native";
import registerRootComponent from "expo/build/launch/registerRootComponent";

if (Text.defaultProps == null) {
  Text.defaultProps = {};
  Text.defaultProps.allowFontScaling = false;
}

if (TextInput.defaultProps == null) {
  TextInput.defaultProps = {};
  TextInput.defaultProps.allowFontScaling = false;
}

registerRootComponent(App);

index.share.js

import { AppRegistry } from "react-native";

// could be any component you want to use as the root component of your share extension's bundle
import ShareExtension from "./ShareExtension";

// IMPORTANT: the first argument to registerComponent, must be "shareExtension"
AppRegistry.registerComponent("shareExtension", () => ShareExtension);

app.json


{
  "expo": {
    "name": "MYAPP",
    "slug": "myapp",
    "scheme": ["com.myapp.app"],
    "owner": "buzzvel",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "main": "index.js",
    "userInterfaceStyle": "automatic",
    "experiments": {
      "tsconfigPaths": true
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "privacyManifests": {
        "NSPrivacyAccessedAPITypes": [
          {
            "NSPrivacyAccessedAPIType": "NSPrivacyAccessedAPICategoryUserDefaults",
            "NSPrivacyAccessedAPITypeReasons": ["CA92.1"]
          },
          {
            "NSPrivacyAccessedAPIType": "NSPrivacyAccessedAPICategorySystemBootTime",
            "NSPrivacyAccessedAPITypeReasons": ["8FFB.1"]
          },
          {
            "NSPrivacyAccessedAPIType": "NSPrivacyAccessedAPICategoryDiskSpace",
            "NSPrivacyAccessedAPITypeReasons": ["E174.1"]
          },
          {
            "NSPrivacyAccessedAPIType": "NSPrivacyAccessedAPICategoryFileTimestamp",
            "NSPrivacyAccessedAPITypeReasons": ["C617.1"]
          }
        ]
      },
      "googleServicesFile": "./GoogleService-Info.plist",
      "supportsTablet": true,
      "bundleIdentifier": "com.myapp.app",
      "splash": {
        "backgroundColor": "#20212C",
        "image": "./assets/splash-dark3.png",
        "resizeMode": "contain",
        "dark": {
          "backgroundColor": "#20212C",
          "image": "./assets/splash-dark3.png",
          "resizeMode": "contain"
        }
      },
      "config": {
        "usesNonExemptEncryption": false
      }
    },
    "android": {
      "googleServicesFile": "./google-services.json",
      "package": "com.myapp.app",
      "splash": {
        "image": "./assets/splash-dark3.png",
        "resizeMode": "contain",
        "backgroundColor": "#20212C",
        "dark": {
          "backgroundColor": "#20212C",
          "image": "./assets/splash-dark3.png",
          "resizeMode": "contain"
        }
      }
    },
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "compileSdkVersion": 34,
            "targetSdkVersion": 34,
            "buildToolsVersion": "34.0.0"
          }
        }
      ],
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ],
      [
        "expo-image-picker",
        {
          "photosPermission": "The app accesses your photos to let you share them with your friends."
        }
      ],
      [
        "expo-document-picker",
        {
          "iCloudContainerEnvironment": "Development"
        }
      ],
      [
        "expo-share-extension",
        {
          "googleServicesFile": "./GoogleService-Info.plist",
          "height": 300,
          "backgroundColor": {
            "red": 28,
            "green": 30,
            "blue": 38,
            "alpha": 1
          }
        }
      ],
      [
        "expo-font",
        {
          "fonts": [
            "./src/assets/fonts/Poppins-Black.ttf",
            "./src/assets/fonts/Poppins-Bold.ttf",
            "./src/assets/fonts/Poppins-ExtraBold.ttf",
            "./src/assets/fonts/Poppins-Light.ttf",
            "./src/assets/fonts/Poppins-Medium.ttf",
            "./src/assets/fonts/Poppins-Regular.ttf"
          ]
        }
      ],
      "@react-native-firebase/app",
      "@react-native-firebase/perf",
      "@react-native-firebase/crashlytics",
      "expo-notifications",
      "sentry-expo",
      "expo-secure-store",
      "expo-av"
    ],
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "extra": {
      "eas": {
        "projectId": "MY_PROJECT_ID"
      }
    },
    "runtimeVersion": {
      "policy": "appVersion"
    },
    "updates": {
      "url": "URL"
    }
  }
}

if you need something more, let me know :)

ViniciusGG commented 8 hours ago

me too

matsantosz commented 8 hours ago

same

Lfseibel commented 8 hours ago

same here, please fix it

marcelojjunior commented 8 hours ago

same