Skip to content
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 tweet share uses the webbrowser in the emulator (Not an error, Explanation inside) #44

Open
pakicoder123 opened this issue Jul 28, 2017 · 11 comments

Comments

@pakicoder123
Copy link

Hi there,
Firstly I'd like to say that I really like the library you guys have built. The main problem I'm having is that when I click "share on twitter", it opens up the chrome browser on my emulator and sets up the tweet over there. On the README, you guys have it showing a popup within the app where you can send the tweet. Is this just because I'm on an Android emulator, or am I missing something? Please help. Thank you.

@doefler
Copy link
Owner

doefler commented Jul 28, 2017

Hi @pakicoder123
Thank you, I am happy you like it 👍

I didn't code the Android part myself, but looking through the files it seems to me that it is just a fallback in case there is no Twitter app installed, so yes it is because you are in the emulator.

See:
https://github.com/doefler/react-native-social-share/blob/master/android/src/main/java/com/barefootcoders/android/react/KDSocialShare/KDSocialShareModule.java

if (doesPackageExist("com.twitter.android")) {
  try {
    tweetViaTwitterComposerClass(shareText);
  } catch (Exception ex1) {
    try {
      tweetViaTwitterDefaultClass(shareText);
    } catch (Exception ex2) {
      tweetViaWebPopup(shareText);
    }
  }
} else {
  tweetViaWebPopup(shareText);
}
private void tweetViaWebPopup(String shareText) throws Exception {
  String tweetUrl = "https://twitter.com/intent/tweet?text=" + shareText;
  Uri uri = Uri.parse(tweetUrl);
  Intent shareIntent = new Intent(Intent.ACTION_VIEW, uri);
  shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  reactContext.startActivity(shareIntent);
}

@pakicoder123
Copy link
Author

Hi, thank you for the quick reply!
And that would make sense, I looked at those lines earlier but now it makes sense. If it wouldn't trouble you too much I would really appreciate if you could answer just one more question. Would you by any chance know how to post images with a status to twitter using the twitter API? I've been working on this for nearly 10+ hours every day and I'm still a novice at React Native so I would appreciate it, if not I completely understand and am grateful for your help.
Thank you again

@angusmccloud
Copy link

@pakicoder123 - definitely agreed. If you get it working to the point of the browser opening you're all set, once it's on a device with the Twitter app it works.

@pakicoder123
Copy link
Author

I should probably clarify, I mean is there any way to stay in the app and post a status with an image, without needing the twitter app downloaded as well?

@doefler
Copy link
Owner

doefler commented Jul 28, 2017

You are welcome @pakicoder123
No, I haven't tried using the Twitter API in React Native for Android myself.
What in particular are you finding difficult?

Hey @angusmccloud

If you get it working to the point of the browser opening you're all set, once it's on a device with the Twitter app it works.

Maybe we should add that as a side note in the README to new people coding for Android. What do you think?

@pakicoder123
Copy link
Author

@doefler
Apologies in advance for the lengthiness of this response, I also want you to know that I greatly appreciate your time, I've been stuck without help for quite a while on this:

So basically I want a user to be able to click a share button and have my app post a tweet with an image I pull from our backend, saying something like "hey everyone, check this out!". But I want it all to be done in-app, with no need for installation of other apps and without the user ever leaving my app. Your library is great but with the caveat that the user will need to either install the twitter app or be temporarily taken into their chrome browser. That's why I was thinking maybe a workaround to this roadblock would be to use a twitter api post request, but I've scoured the webs and the only thing I found was "react-native-twitter", which is capable of posting a status with an image: the only problem is that the image needs to be pulled from the device's camera roll, apparently that's a special type of image object in react native. Please let me know if you could offer any insight into this problem

@doefler doefler changed the title Android share popup not popping up Android tweet share uses the webbrowser in the emulator Jul 28, 2017
@doefler
Copy link
Owner

doefler commented Jul 28, 2017

@pakicoder123

I have no experience coding for Android so can't really give any educated advice.
Also saw "react-native-twitter", which seems like an option.

My initial thoughts:

@pakicoder123
Copy link
Author

Thank you for all your advice, will definitely read up more on that link and try out your suggestions. My sincere appreciation for your talented coding, time, and help.
Best regards!

@doefler
Copy link
Owner

doefler commented Jul 28, 2017

@pakicoder123

You are welcome, let's keep it open in case other people are wondering about the web popup.

@doefler doefler reopened this Jul 28, 2017
@doefler doefler changed the title Android tweet share uses the webbrowser in the emulator Android tweet share uses the webbrowser in the emulator (Not an error, Explanation inside) Jul 28, 2017
@pakicoder123
Copy link
Author

Sounds fine by me, I'm new to github issues too lol. Hope other people find what they're looking for too, have a good day

@doefler
Copy link
Owner

doefler commented Jul 28, 2017

Same here 😄
You too have a nice day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants