-
Notifications
You must be signed in to change notification settings - Fork 923
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
[Android] Share.open always return success: false & dissmissedAction: true #1059
Comments
I investigated this, but I'm not sure how to fix it. This also happens with However, the
I wonder if we can send 'success' at that point as the @mikehardy, any thoughts on this? |
@kaioduarte looks like an incorrect assumption in the native android code here yes, I'm not sure what you mean by RESULT_CANCELED not being accurate, as it appears accurate, I think you might mean "complete" - in that RESULT_CANCELED is accurate when it is the result code but it is only one integer and the result code could be any integer, with no other integers currently handled (so the current solution is incomplete)? It does appear that to be complete, any result code that comes back as an activity result matching the request code should be handled. Ideally the interface would propagate the result code back up to javascript / API consumer then by maybe switching on result code and calling react-native-share/src/index.tsx Line 73 in 5ed224b
|
@mikehardy, My point is that we can receive that code for more than one scenario (even for successful sharing). I did some tests, and all of them returned the same code:
It doesn't seem trivial to get the proper code. Otherwise, I guess Expo or RN would handle that. |
Ah - there was an assumption in my comment that "accurate" was not the right word. But if you've done the real-world testing (instead of my blah blah blah theory / documentation reading) and it really is just coming back as RESULT_CANCELED all the time, including on successful share then it does seem intractable, and maybe just PR'ing a returns-every-time-but-is-documented-to-be-useless-with-regard-to-return-value change is the thing to do |
@kaioduarte @mikehardy is there anything we can do to help to fix this? Ready your comments I'm still not sure if this is an issue with the library or with the RN itself 🤔 |
If someone proposes a well-reasoned PR, it gets merged and released - that's the thing to do if there's an issue |
Yes, I know how OSS works. I'm not demanding a solution, I'm asking how I can help. I want to understand the issue so I can do some research. I'm not an android developer so doubt I could submit the PR, but maybe I can test, debug, provide info, or open an issue in the RN repo if that's necessary. Do you mind explaining what do you mean by: "PR'ing a returns-every-time-but-is-documented-to-be-useless-with-regard-to-return-value change is the thing to do" ? "It doesn't seem trivial to get the proper code. Otherwise, I guess Expo or RN would handle that." Makes me think is an issue with RN itself |
I believe the issue is actually the Android system not returning a useful value, and Expo and react-native (core) paper over the issue by just returning success all the time - we should do the same - just make a change where the actual return value that comes back in onActivityResult is ignored and you return success no matter what, and match it with a documentation change that explains the return value is useless because Android doesn't provide a valid return value, and that should do it |
Should this one be closed after merging #1078? |
No, I tested it but the bug is still there 😔 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and i will leave this open |
android share return value discussion should stay focused here, it has the most information. Open to PRs, but everyone understand - you need to read the comments ☝️ and after reading them the next step is a PR. Please post a PR if you're interested in a behavior change. |
I'm revisiting this issue as my react-native app would like to be aware if an app was used or the Sharesheet was simply dismissed. As I was playing around with the code, I found that the However, as the code stands, this method is never invoked and I found this is due to a couple lines of code that, when removed/changed, I think pretty much solves the issue here, at least for the
By doing this, the JS will return an error ( However, before I submit a PR, I would like to know why these things currently exist and what happens if this were to be changed. |
@iainmaryanow very interesting! Looks like: |
Thanks @mikehardy, I appreciate the quick response. I understand why #1 is necessary, however, I cannot find anywhere why adding this flag is causing the For #2, I don't see why this was necessary for the remediation as it does not say to set the class, only the action, package, and component. In either case, I am quite stumped how this is silently breaking the behavior as I don't really know much about Android development beyond what I've looked at for this issue. The only other thing I can think of is using |
Well, for my part, as long as we don't suffer app store rejections (pending intent vulnerability), and work on API32 (immutable flag), anything that fixes the feature would be welcome 😅 |
also Share.open always returns rejected error on telegram share |
same here always 'User did not share' on android |
This is still an issue :/ |
I am also facing same issue. any update on how to fix it or any work around? |
also facing same issue |
Same issue with these versions when content is shared in Telegram or Discord.
|
Still this issue |
1 similar comment
Still this issue |
any updates? |
Still this issue |
Steps to reproduce
Share.open
with androidfailOnCancel: false
Expected behavior
The promise resolves if the user shares or dismisses, and the returned object contains
success
anddismissedAction
properly set.Actual behavior
The returned object always contains
success: false
anddismissedAction: true
no matter if the user shared or dismissed the share sheet.Environment
react-native-share
Version: 6.4.0 (latest)
Repro
I also tried without using
failOnCancel: false
but then the issue #784 happens :(The text was updated successfully, but these errors were encountered: