Trying to access other libs in release mode
kpfefer opened this issue · comments
RN Native : 0.59.8
RN Share Extension : 2.0.0
I am trying to send images to my main app using deep linking, it works great in debug but I am having an issue when releasing.
This is the logs I am getting when I trigger the share action :
2019-07-27 21:39:12.937441+0200 MyExShare[40338:9750890] Failed to inherit CoreMedia permissions from 40329: (null) 2019-07-27 21:39:13.411 [error][tid:com.facebook.react.JavaScript] null is not an object (evaluating 'o.SIGN_IN_CANCELLED') 2019-07-27 21:39:13.413575+0200 MyExShare[40338:9750899] null is not an object (evaluating 'o.SIGN_IN_CANCELLED') 2019-07-27 21:39:13.417 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: null is not an object (evaluating 'o.SIGN_IN_CANCELLED') 2019-07-27 21:39:13.418 [error][tid:com.facebook.react.JavaScript] Module AppRegistry is not a registered callable module (calling runApplication)
So it looks like it's trying to access react-native-google-signin which I am using in my main app. But I have no idea why it's trying as I thought I separated correctly my entry files. I have a separated share.ios.js file :
import {AppRegistry} from 'react-native'; AppRegistry.registerComponent('MyExShare',() => require('./Share').default)
And this is my Share.js:
import React, { Component } from "react";
import Modal from "react-native-modal";
import ShareExtension from "react-native-share-extension";
import { Text, View, TouchableOpacity, Linking, Alert, Platform } from "react-native";
function JSONtoBase64(json) {
var Buffer = require("buffer/").Buffer;
return Buffer.from(JSON.stringify(json)).toString("base64");
}
export default class Share extends Component {
constructor(props, context) {
super(props, context);
}
async componentDidMount() {
const data = await ShareExtension.data();
if (Platform.OS === "ios") {
const RNFetchBlob = require("rn-fetch-blob").default
const appGroupPath = await RNFetchBlob.fs.pathForAppGroup("group.org.myapp");
const filename = data.value.replace(/^.*[\\\/]/, "");
const destination = `${appGroupPath}/${Math.random().toString(36).substring(7)+filename}`;
await RNFetchBlob.fs.cp(data.value.replace("file://",''), destination);
data.value = destination;
const photos = JSONtoBase64(data);
ShareExtension.openURL(`myapp://gallery/upload/${photos}`);
} else {
const photosAndroid = JSONtoBase64(data);
Linking.openURL(`myapp://gallery/upload/${photosAndroid}`)
}
ShareExtension.close();
}
render() {
return (
<View/>
);
}
}
I have the following libs linked to MyShareEx :
I am trying to understand what makes it work in debug versus release... Is there a difference in the way bundles are generated ?
I'd appreciate any tips :)
@kpfefer were you able to solve this? I'm facing the exact same issue.
working on debug but shows these errors in release mode...
@sahildeliwala I was not able to fix it but I chose an other implementation.
In my case I just wanted to redirect to the main app using deep linking and not display anything. So I wrote my own share extension using swift to do that. I am still using this extension to handle Android though.
@NikitaPFE I am using this code : https://stackoverflow.com/a/44499222/995349
Just made a few tweaks to it for my personal case (encoding data to base64 and passing it to the URL)