votrai123 / integrate-multiple-react-native

8 stars 4 forks source link

Cannot switch Parent App to Child App when use react-native-map #1

Closed NguyenManh1404 closed 10 months ago

NguyenManh1404 commented 10 months ago
`import React from 'react';
import {
  Dimensions,
  NativeModules,
  SafeAreaView,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
} from 'react-native';
import MapView, {Callout, Marker, PROVIDER_GOOGLE} from 'react-native-maps';
import AppInfo from './app.json';

const {height} = Dimensions.get('window');
const {ConnectNativeModule} = NativeModules;
const App = props => {
  return (
    <SafeAreaView>
      <View>
        <MapView
          provider={PROVIDER_GOOGLE}
          zoomControlEnabled={true}
          zoomEnabled={true}
          style={{
            height: height - 200,
          }}
          region={{
            latitude: 16.069560532577032,
            longitude: 108.23408695899637,
            latitudeDelta: 0.015,
            longitudeDelta: 0.0121,
          }}>
          <Marker
            coordinate={{
              latitude: 16.069560532577032,
              longitude: 108.23408695899637,
            }}>
            <Callout>
              <Text>Address</Text>
            </Callout>
          </Marker>
        </MapView>
      </View>
      <View>
        <Text style={styles.title}>App One</Text>
        <Text style={styles.content}>
          Here props from super app: {JSON.stringify(props)}
        </Text>
        <TouchableOpacity
          style={styles.button}
          onPress={() => {
            ConnectNativeModule?.closeApp(AppInfo.name);
          }}>
          <Text style={styles.content}>Close App</Text>
        </TouchableOpacity>
      </View>
    </SafeAreaView>
  );
};

export default App;

`
votrai123 commented 10 months ago

Hi @NguyenManh1404 ,

  1. Have you ensured that react-native-screens is installed in the supper and mini apps?
  2. In the supper app, we also need to install the same library as the mini app? You need to install react-native-maps in the supper app
  3. In the path android/app/src/main/java/com/superapp/miniapp/MiniAppActivity.java, line 60, you need to add the line new MapsPackage() to supper using lib
  4. Finally, you rebuild the bundle file and rebuild the project Thanks
NguyenManh1404 commented 10 months ago

Hi @NguyenManh1404 ,

  1. Have you ensured that react-native-screens is installed in the supper and mini apps?
  2. In the supper app, we also need to install the same library as the mini app? You need to install react-native-maps in the supper app
  3. In the path android/app/src/main/java/com/superapp/miniapp/MiniAppActivity.java, line 60, you need to add the line new MapsPackage() to supper using lib
  4. Finally, you rebuild the bundle file and rebuild the project Thanks

Is not work when done follow 4 step. APP continue crash when swich app my repo: https://github.com/NguyenManh1404/switchApp

votrai123 commented 10 months ago

Are you missing step 3?

NguyenManh1404 commented 10 months ago

3. new MapsPackage()

I can not import on android studio code , I think it auto link

Screenshot 2023-11-08 at 15 48 19
votrai123 commented 10 months ago

import from here!!

image
NguyenManh1404 commented 10 months ago

Why I can not import. Can you open this project on android studio code

Screenshot 2023-11-08 at 17 09 52
votrai123 commented 10 months ago

In Android Studio. Have you synced Gradle yet?

NguyenManh1404 commented 10 months ago

It works, many thanks @votrai123 . But it not work on IOS platform

votrai123 commented 10 months ago

@NguyenManh1404 #3