Skip to content

Native Script support? #110

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

Closed
aaweb opened this issue Mar 28, 2016 · 19 comments
Closed

Native Script support? #110

aaweb opened this issue Mar 28, 2016 · 19 comments

Comments

@aaweb
Copy link

aaweb commented Mar 28, 2016

Hey guys

More of question than an issue: Is there any reason not to use this in combination with Native Script on iOS and Android?

I'm looking for a unified way of talking to firebase across web and mobile, but ideally without losing things like offline support on the native platform SDKs.

Cheers and keep up the great work!
Andy

@lf-alves
Copy link

lf-alves commented Apr 5, 2016

+1

I'm currently trying to integrate Angular2 and Nativescript and I would like to use firebase as well. I've created a simple hello world app (if you have nativescript installed, just run tns create my-app-name --template https://github.com/NativeScript/template-hello-world-ng) and I was wondering how I can start using angularfire with it. My biggest problem seems to be the System.js part since the nativescript project doesn't have an index.html or anywhere I can load modules with System.js. Can anyone help?

@davideast
Copy link
Collaborator

I'm not a NativeScript pro, so I'm not exactly sure what needs to be done to get AngularFire included.

@burkeholland any ideas?

@burkeholland
Copy link

Without knowing the internal workings of AngularFire, my gut reaction is that an {N} plugin needs to be created that includes the Angular wrapper.

@lf-alves
Copy link

Damn... That's sad to hear. I mean, the only reason I chose nativescript over react native to develop native apps was because I could leverage my angular skills when creating things with nativescript. Really hope this process of integrating {N}, angular and firebase becomes more and more seamless over time as they seem to be a perfect fit for building cross platform applications.

@davideast
Copy link
Collaborator

@burkeholland and @LuisOliveiraAlves.

No hill to tall to climb. There were serious issues with Firebase + ReactNative from day one (RN didn't support web sockets... at all). But we helped sort that out and now it's awesome. We can do the same with {N}!

@burkeholland
Copy link

There is nothing here that isn't doable. Someone just needs to create the plugin. In fact, the nativescript-firebase already exists.

In fact, if you would be willing to start it, @davideast and I can both help. Come join our NativeScript Slack Channel and let's get it started. There are several Angular plugins that people have built already.

@davideast
Copy link
Collaborator

@burkeholland is 100% right. I'm closing this issue right now, but we'll circle back around it once the library is released.

@aaweb
Copy link
Author

aaweb commented Jun 27, 2016

Any news on this now that Angularfire2 is on Firebase SDK 3?

@fricker
Copy link

fricker commented Oct 28, 2016

@burkeholland and @davideast

my gut reaction is that an {N} plugin needs to be created that includes the Angular wrapper

Someone just needs to create the plugin

I have started creating a framework for Angular2 web apps that uses AngularFire2. I am trying to evaluate the feasibility of creating a NativeScript plugin for AngularFire2 so that my Angular2-based framework can leverage AngularFire2 consistently within web and mobile apps.

AngularFire2 is dependent on the Firebase library that targets a web browser while the NativeScript plugin by Eddy Verbruggen referenced in this issue is dependent on native Android/iOS implementations of Firebase. Unfortunately Eddy's work does not appear to be applicable to what I need. The Firebase library that targets browsers assumes access to browser window location, local storage, etc. which NativeScript's support for Angular2 does not include.

It seems that I would need to do some non-trivial hacking on the Firebase library that AngularFire2 uses to create this NativeScript plugin but that library is proprietary and mostly obfuscated. Any suggestions on how to proceed?

@fmoessle
Copy link

When trying to use angularfire with nativecscript i get the following error message:

ERROR Error: Could not find module 'fs'.

I know there is a plugin for firebase https://github.com/EddyVerbruggen/nativescript-plugin-firebase but i want to use angularfire, because of the nice integration of observables which is pretty amazing.

Any ideas?

@itsdante
Copy link

itsdante commented Aug 8, 2017

Anyone ever tried this ?
https://github.com/aguzubiaga/nativescript-angularfire2
I found it lying around on git, but i did not see any reviews or comments about it.
I'm still a new geek at {N} so please tell me if im wrong in any way. Thanks

@kinggolf
Copy link

@davideast @burkeholland @EddyVerbruggen @fricker @VladimirAmiorkov
I would like to reopen this discussion and if we can agree on a plan, I am willing to do what it takes to help drive this forward so that we can use AngularFire2 functionality in NativeScript.
As @fricker stated previously, AngularFire2 only interfaces to firebase-js-sdk, so therefore is not directly compatible to run in NS. @EddyVerbruggen 's awesome nativescript-plugin-firebase allows NS apps to interface to the native firebase sdk's.

To me a reasonable approach would clone AngularFire2 into a new NS plugin and replace the dependency on firebase-js-sdk with nativescript-plugin-firebase. However, it seems like the firebase api's used in AngularFire2 are not implemented in nativescript-plugin-firebase. The AngularFire2 api's calls to firebase are:
firebase.app & .app.App
firebase.auth.Auth & .auth.Error
firebase.database.Database & .database.Reference & .database.DataSnapShot & .database.ThenableReference
firebase.messaging.Messaging
firebase.storage.Storage
firebase.Promise
firebase.initializeApp
firebase.User

There is a User in nativescript-plugin-firebase, not sure if it the same, and we should be able to replace above initalizeApp with the already existing init method, but none of the api's seem to have a match. Would it make sense to add these api's into nativescript-plugin-firebase to enable usage of NS AngularFire2? If this is possible, then users already familiar with AngularFire2, would very easily be able to apply it to their NS apps. I am very interested in what @davideast and @EddyVerbruggen think about this, as well as anyone else. And again I am willing to what it takes to get this implemented, but I will definitely need some direction/assistance. Thanks all.

@EddyVerbruggen
Copy link

EddyVerbruggen commented Nov 24, 2017

Hey @kinggolf I ❤️ the idea of making the NativeScript plugin compatible with AngularFire2, but there are two main issues preventing that:

  1. Make the NativeScript plugin compatible with the Web API (as that's what AngularFire2 is built on top of). That's currently work in progress. UPDATE: Version 5.0.0 of the plugin was released, which includes web API support for a lot of things, most notably Firestore.

  2. FIgure out how require('firebase/app') can be rewired to actually do require('nativescript-plugin-firebase/app'). The easy way out would be to fork the AngularFire2 repo and change those require calls, but I'd rather make it 'plug & play'. So perhaps a hook is needed in the NativeScript plugin, but I'd love to learn any other tricks that can make this happen.

@someguy314
Copy link

@EddyVerbruggen @kinggolf
Is there any news on this endeavour, now that nativescript-plugin-firebase is on version 6 or did a different solution pop up regarding AngularFire2 and NativeScript?

@kinggolf
Copy link

@someguy314 - nothing on my end, but I'm still a huge fan of AngularFire2!

@larssn
Copy link
Contributor

larssn commented Sep 19, 2018

@someguy314 I've looked into it, and nativescript-plugin-firebase is a bit behind the web sdk. If it was brought up to date, simply changing the references in angularfire2 should be fairly simple (as has been mentioned); in theory.

I'll see if I can allocate some free time (which I have none of)

@dolanmiu
Copy link

dolanmiu commented Nov 22, 2018

Any progress on this?

I have slowly began to realise this is very important because otherwise one would need to use this.zone.run() to make Angular run change detection:

I have to do this everywhere:

this.feed$ = Observable.create((observer) => {
            this.collection.onSnapshot((snapshot) => {
                this.zone.run(() => {
                    const feedItems = snapshot.docs.map((docSnapshot) => docSnapshot.data() as FeedItem);
                    observer.next(feedItems);
                });
            });
        });

I mean, its not a show stopper, but it bugs me personally none the less.

@DustinJSilk
Copy link

Has anyone managed to make any progress on this at all? I'm happy to be involved in supporting this, though now that the issue is so old there might be a potentially easier solution now?

@prestopasto
Copy link

@EddyVerbruggen Maybe we could look at RxFire in NativeScript first (instead). It doesn't require (firebase/app) in the library, so it should get around your point #2 above.

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