Nativescript-plugin-firebase: support twitter

Created on 5 Jun 2018  Â·  16Comments  Â·  Source: EddyVerbruggen/nativescript-plugin-firebase

support twitter ?

Android Authentication enhancement iOS

Most helpful comment

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

All 16 comments

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

@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!

@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.

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.

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

Safe to assume no updates yet?

@ScottAtRedHawk @goyote
We use Ioinic now.

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

+1
Maybe?

@EddyVerbruggen still no update for this?

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

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

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?

Hi @EddyVerbruggen

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

@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.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SBD580 picture SBD580  Â·  3Comments

yencolon picture yencolon  Â·  4Comments

phatakrajan picture phatakrajan  Â·  4Comments

bunower picture bunower  Â·  3Comments

romandragan picture romandragan  Â·  3Comments