-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dont show modal on iOS #18
Comments
I have the exact same problem, would be great If we could figure out why :).. Im using React native v.0.37... @luisfuertes @alinz please ping me if you find a solution :) |
My versions:
|
Please share your code if you want help. The issue is relatively broad to guess from. |
@TheSisb ofcourse, iOS Extension: MyCustomShareEx.m
My index.ios.js:
My share.ios.js:
|
Build your regular project, then build your ShareExtension project. This is a very important step...
I just built a new project with minimal resources and things worked. Try using a |
+1 |
I try to put: But on xcode console and on safari console (sharing from safari) dont show any log. @parkerdan you know how can i continue fixing this? EDIT: If i execute MyShareEx project on Safari, had this log, and print my NSLog:
With Capabilities, App Groups enabled in my project target and in share extension target new log when i execute MyShareEx on safari:
|
@luisfuertes, you got a pink box to show...so you did something right. If you can't get just a simple pink box on your project, then it's a configuration issue. If you got the pink box, then tried to make your share extension more complex...obviously something went wrong with your JavaScript. If so, share you actual Javascript component/code and I will look at it and try to point out where you went wrong. Remember this: |
@parkerdan all my config: When i add But dont load react view. Has a problem with AppRegistry
And share.ios.js code (is the same that other proyect where it works:
|
I'm facing the same error here. AppRegistry.registerComponent('App', () => App)
AppRegistry.registerComponent('MyShareEx', () => Share) When I comment all the |
I try: MyShareEx.m
And index.ios-extension.js
And now it works on iOS simulator, but doesn't work on real iOS device. Log error: |
@luisfuertes, I have no problem using this, and as far as I know the doc is pretty much describe the process. Have you looked into this section of doc? https://github.com/alinz/react-native-share-extension#test-on-device-without-dev-server |
Yes, i have that script implemented on my code. But it doesnt work. On iOS device have the same issue. Dont show react view and log: Im working on it, if i have some news, i will post here. EDIT: Script must add only on extension or on main project too? |
If i comment all index component work on iPhone device, like @vinicius-sabadim
@alinz you know how can i fix it with my normal index.js? EDIT: I try to add but it cant compile with -ObjC ( If i remove -ObjC from Other Linker Flags, share doesnt works. |
@luisfuertes can you change the workflow. Instead of login in the user in share extension, they should login in your app first and then you can access the the token from share extension. I haven't actually see any apps let's you login in share extension. They usually prompt you to log in inside app or use deep liking to open up your app. At the moment, I'm doing exactly like that in my app. If users are not logged in, I push them back to main app for login procedure. |
I dont use google login on extension. You can see my extension code some post before. The google import is in my main app. If i comment it (and others). Extension works. But if i import google login (only import, not use) on my main app. Extension doesnt works |
@luisfuertes There is something wrong with the google. We had some problem similar here and when something goes wrong, the react-native return a generic error.
|
@adrianotadao thanks for answer. I tried to add |
@luisfuertes I need to confess. React-native is almost a magic box. =l I don't know how can I help you. I'm having problems here and it's very painful |
@luisfuertes can you provide a sample project/repo so I can jump on it. I might have more clear visions and solutions once I see the problems on my computer. |
Hey guys. Any updates in this issue? |
@ollar I can't go on and investigate on this issue unless some one creates a sample project. I am using this project into couple of apps and so far no problem. |
Hi, guys, @alinz awesome work, I am using react-native-share-extension, everything goes good, but I am facing a little problem, I am trying to use Alert API from react-native package, but it doesn't work, anyone has worked with that before ? here my code : /**
* Created by juordergonzalezquinonez on 06-02-17.
*/
import React, { Component } from 'react'
import ShareExtension from 'react-native-share-extension'
import {
Text,
TextInput,
View,
TouchableOpacity
} from 'react-native'
export default class Share extends Component {
constructor(props, context) {
super(props, context)
this.state = {
isOpen: true,
type: '',
value: '',
raw: ''
}
}
async componentDidMount() {
try {
const data = await ShareExtension.data();
const { type, value } = data;
this.setState({
type,
value,
raw: JSON.stringify(data)
})
} catch(e) {
console.log('errrr', e)
}
}
onClose() {
Alert.alert('title', "My message to alert!!!");
//ShareExtension.close();
}
closing = () => {
this.setState({
isOpen: false
})
};
render() {
return (
<View style={{ flex: 1, borderColor: 'black', backgroundColor:"pink", opacity: 0.5, borderWidth: 1}}>
<TouchableOpacity onPress={this.onClose}>
<Text>Close</Text>
<Text>type: { this.state.type }</Text>
<Text>value: { this.state.value }</Text>
<View style={{marginVertical: 20}}/>
<Text>RAW: { this.state.raw }</Text>
</TouchableOpacity>
</View>
)
}
} Another question that comes to my mind is, how you can use : {View, Text, TouchableOpacity} if you are not importing these components at the top of the file ? Thanks. |
@johuder33 unfortunately that not possible. the reason is that, I'm instantiating share extension with Just the controller and there is no application window. Alert requires an application window. I think it is possible but at the moment I am busy with stuff but I would accept PR for anyone who wants to implement it. Your alternative way is using import React, { Component } from 'react'
import { StyleSheet, View, Text, Alert } from 'react-native'
import Modal from 'react-native-modalbox'
import ShareExtension from 'react-native-share-extension'
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
alert: {
width: 200,
height: 100,
backgroundColor: 'red',
alignItems: 'center',
justifyContent: 'center'
}
})
export default class Share extends Component {
constructor(props, context) {
super(props, context)
this.state = {
showAlert: false,
message: ''
}
}
onClose() {
ShareExtension.close()
}
showAlert(message) {
this.setState({
showAlert: true,
message: message
})
}
async componentDidMount() {
const result = await ShareExtension.data()
setTimeout(() => {
this.showAlert(result.value)
}, 3000)
}
render() {
return (
<Modal backdrop={false}
style={{ backgroundColor: 'green' }}
position="center"
isOpen={true}
onClosed={this.onClose}>
<View style={styles.container}>
<Text>This is Share Extension2</Text>
</View>
<Modal backdrop={false}
style={styles.alert}
position="center"
isOpen={this.state.showAlert}>
<View style={styles.container}>
<Text>{this.state.message}</Text>
</View>
</Modal>
</Modal>
)
}
} hmmm, about your second part of your question, I don't quite get it. can you elaborate on that? if you don't import them then you can't use them unless you wrap them with another component inside another file and import the custom component into this file. |
@alinz I understand, I would like to help you with a PR, but I am not a Objetive-C developer, I am learning right now, because I would like to build some module for RN, now concerning about my second question, please forget about it, I don't know what I was thinking about at that moment hahaha!. But there is a thing that I can't get it. how can you debug your share extension ? I tried enabling remote debugging but not luck, do you know any way to debug into the share extension app ? Thanks |
@alinz great, now it`s working, thanks too much. |
Hey @alinz! You said:
Are you doing this by using React-native's Linking library? I'm trying to achieve this by doing something like this in the share extension if the user is not logged in:
Is this what you did? Doing this doesn't seem to be doing anything for me. I tried typing myapp:// in safari and it does execute the applink correctly edit: I'm reading that this is not possible? http://stackoverflow.com/questions/31967734/open-container-app-from-share-extenion |
@juhaelee you just have to remember that in order for Linking to work user interaction must be performed. What I mean by this is user must initiate the trigger by tapping on request. When you type the url in safari and hit go, you as a user trigger the start. what you have to do is show a message or open the dialogue to ask the user to launch the app, once the user accept then the process will work. In other hand, you can't programatically open the any app without user approval. |
@alinz According to you,
Do I have to try something else? Sorry, for beginner's question.. I do not have ios knowledge. |
@simsim0709 AsyncStorage isnt the same API that NSUserDefaults, you can use this component to share token with NSUserDefaults: https://github.com/alinz/react-native-swiss-knife |
@simsim0709, as @luisfuertes mentioned, I have implemented react-native-swiss-knife to fix this issue of sharing anything between App and Share extensions. let me know how things go. |
@alinz and about this bug, for clarify, if you install some component incompatible with |
@luisfuertes unfortunately even if I remove it, it won't be compatible anymore as of version 41 of react-native. from 41 they will add the I think it's time for open PR to those library and make them compatible with these flags. |
@adrianotadao @alinz I have raised react-native-google-signin/google-signin#251 as I am having the same issue.
We cannot include the Google library as it is not compatible with ObjC. Any ideas on how to progress with this problem? |
Unfortunately this is not the react-native-share-extension issue anymore. one quick advise, do not let user login with share extension. Share extension meant to be do one thing and one thing only. The user has to login into your main app and your main app share the credential with share extension. I'm going to close this issue. Feel free to continue the discussion. |
Agreed about the login - however, I am not doing that here. As with @adrianotadao earlier, the login is from the main app. TBH I am a bit lost as to why the extension is even trying to include this. |
Same...... |
@xuechinahb the link that you provided is broken. is this a private repo? |
@alinz try again , or go to my repos, the lastest one is it. |
It is much strange. Sometimes it can show modal quickly, or delay long time . Sometimes Safari has no response, Safari is dead, I must kill Safari and restart it. Moreover, as mentioned above, nothing happened. |
@luisfuertes @njt1982 Guys. I found a way to hack through this. In fact, you can even skip some of the libraries in this
In the In your The reason for this is that, One thing that I still haven't figured out is if when the app is bundled and exported, how will RN bundle both of the js files that are needed for the main app and the share extension. I will need to try exporting the app and try it out. Anyone with more knowledge on this can enlighten me? Hope that this will help. |
@ncnlinh that is really good and as you mentioned in the last section, unless you want to hack the bundler itself. And that is why I put the whole registration there. one way to solve this elegantly without doing too much hack is this. you simply use
|
@ncnlinh I did exactly the same thing, and it work great on Simulator, but doesn't load at all on real device. It there any fix out there or is this dead ? And if I try what's in the tutorial, It show the view (with the red background) but doesn't show my react native share view. |
Hi @alinz , I am using the react-native-share-extension in one of my project. I have integrated the package as suggested. I am able to see the UI when I am sharing the text in Android. But in iOS, I can't see the UI.
Now, whenever I am importing the I want to load other UI from share extension. Can you guide me how can I achieve it or point out what I am missing here. |
Creating a new index file for share component fixed it for me |
Hi, thanks for this component.
On iOS i think all its fine configured but when i press on share to MyAppShareEx, nothing happen. It dont show any popup.
Some idea? If need some code of my config ask me and i will post it.
Thanks!
The text was updated successfully, but these errors were encountered: