EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 441 forks source link

support twitter #744

Open zuohuadong opened 6 years ago

zuohuadong commented 6 years ago

support twitter ?

EddyVerbruggen commented 6 years ago

That would be great. PR's more than welcome!

brownkevg commented 5 years ago

@EddyVerbruggen First off thanks for your work on this plugin! I'm currently using it on a project and was wanting to create a PR for twitter login. If you could point me in the right direction and give me some pointers it would much appreciated... I'm new to this whole plugin thing and wanting to dive into it. Thanks!

EddyVerbruggen commented 5 years ago

@brownkevg Awesome, your help is much appreciated!

I was typing a lengthy instruction for how to go about this, but then I found this and this.

So the way Firebase is currently integrating with Twitter is deprecated and will change. It would be a bit silly to start working on this now I'm afraid. But if you really need it, I won't stop you doing a bit of work that will need to be refactored in a few months. So here goes anyway:

So to add Twitter support, let me tell you what my steps would roughly be:

  1. Fork this repo and clone your fork to your local development machine. Then cd src and run npm run setupandinstall (just skip through the plugin y/n prompts you'll get as those are ignored in this case). Then see if the demo app runs: npm run demo.ios (or .android).
  2. Go to https://firebase.google.com/docs/auth/ios/twitter-login and check the iOS requirements for adding Twitter support. It looks like Twitter support needs to be added to the demo app, so I'll take care of that in case you want to see this through (let me know!).
  3. Because we need to use (the deprecated) TwitterKit SDK, you'll have to change publish/scripts/installer.js. Make it ask the user during installation whether or not Twitter auth is used and add the required TwitterKit Pod accordingly. After running the demo app again it's really helpful to have code completion when working with this new SDK, so run this npm script and copy over the generated objc!TwitterKit.d.ts file to this folder and reference it in this file
  4. Now open this file and add TWITTER to the enum of supported auth providers.
  5. Now look at how we've integrated Google login. It's probably pretty similar, so copy-paste that block of code and look at the docs for the exact details.
  6. Same for Android, so add the library mentioned here to the installation script and copy-paste one of the other auth providers.
brownkevg commented 5 years ago

Yah, sounds like it'll be worth it to wait until they come out with the new way of logging in. Let me know if you hear when that happens. I'll also try to look out for that as well. Also thanks for the instructions, I may try playing around with it just to get my feet wet.

ScottAtRedHawk commented 5 years ago

Any updates on this? Is there a new way of logging in that can be implemented in this plugin? Thanks!

goyote commented 5 years ago

Safe to assume no updates yet?

zuohuadong commented 5 years ago

@ScottAtRedHawk @goyote
We use Ioinic now.

ScottAtRedHawk commented 5 years ago

We used a fork of the nativescript-twitter plugin and just handle it outside of firebase.

imperatormk commented 4 years ago

+1 Maybe?

Lavhe commented 4 years ago

@EddyVerbruggen still no update for this?

EddyVerbruggen commented 4 years ago

@Lavhe not from me, but if you feel like taking a stab at it, then please take not of my PR hints above.

Lavhe commented 4 years ago

I am working on it now, it looks fun, problem is i do not have a mac, so i will test for android only

Lavhe commented 4 years ago

I did it finally

:partying_face: :partying_face: :partying_face:

image image

Just that it is for android only, who here can port this to IOS?

Lavhe commented 4 years ago

Hi @EddyVerbruggen

Must i open a PR with just android support? or you need IOS as well?

EddyVerbruggen commented 4 years ago

@Lavhe As long as it's very clear from the readme, and the app doesn't crash on iOS, then I don't mind supporting only Android for the time being.

robario commented 4 years ago

I used OAuth for twitter login. I patched firebase.ios.js like this to make app can handle oauth callback with applicationOpenURLOptions.

       appDelegate.prototype.applicationOpenURLOptions = function (application, url, options) {
+          if (typeof FIRAuth !== "undefined") {
+            return FIRAuth.auth().canHandleURL(open);
+          }

And use OAuth sign-in

const provider = FIROAuthProvider.providerWithProviderID("twitter.com");
const UIDelegate = null as unknown as FIRAuthUIDelegate;
FIRAuth.auth().signInWithProviderUIDelegateCompletion(provider, UIDelegate, (authResult, error): void => {
  // if authResult then firebase.getCurrentUser() returns logged-in user.
});

In addition, Android worked fine without any patch.