angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Native Script support?

Open aaweb opened this issue 10 years ago • 19 comments

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

aaweb avatar Mar 28 '16 10:03 aaweb

+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?

lf-alves avatar Apr 05 '16 21:04 lf-alves

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

@burkeholland any ideas?

davideast avatar Apr 09 '16 22:04 davideast

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

burkeholland avatar Apr 10 '16 00:04 burkeholland

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.

lf-alves avatar Apr 10 '16 17:04 lf-alves

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

davideast avatar Apr 11 '16 12:04 davideast

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.

burkeholland avatar Apr 12 '16 02:04 burkeholland

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

davideast avatar Apr 13 '16 12:04 davideast

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

aaweb avatar Jun 27 '16 23:06 aaweb

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

fricker avatar Oct 28 '16 07:10 fricker

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?

fmoessle avatar Jan 14 '17 10:01 fmoessle

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

itsdante avatar Aug 08 '17 14:08 itsdante

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

kinggolf avatar Sep 20 '17 17:09 kinggolf

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.

EddyVerbruggen avatar Nov 24 '17 11:11 EddyVerbruggen

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

someguy314 avatar Jun 11 '18 22:06 someguy314

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

kinggolf avatar Jun 13 '18 02:06 kinggolf

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

larssn avatar Sep 19 '18 10:09 larssn

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.

dolanmiu avatar Nov 22 '18 16:11 dolanmiu

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?

DustinJSilk avatar Oct 29 '19 08:10 DustinJSilk

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

prestopasto avatar Jun 13 '20 12:06 prestopasto