transistorsoft / flutter_background_geolocation_firebase

Firebase proxy for Flutter Background Geolocation SDK
MIT License
21 stars 7 forks source link

How about using a transformer to tranform the location Snapshots before uploading to fireStore? #20

Closed erluxman closed 3 years ago

erluxman commented 3 years ago

Right now we upload the default data as payload to firestore. And we need to listen in function to changes in order to make some changes in those documents.

How about adding a transformer that looks something like this? We can even enable something similar to change the document ID?

 BackgroundGeolocationFirebase.configure(BackgroundGeolocationFirebaseConfig(
        locationsCollection: collectionName,
        geofencesCollection: geofenceName,
        transformer: (rawPayload){
            return transformPayload(rawPayload);
        },
        documentId : (rawPayload) => getDocumentId(rawPayload),
        updateSingleDocument: false));
christocracy commented 3 years ago

Because that doesn't work for the Android headless case.

Use Firebase functions.

erluxman commented 3 years ago

Thanks for the quick response 🙏🏻

We are also trying to upload to firestore after some filtering without this proxy module in our current implementation.

Is there any documentation/issue that I can read why/how it doesn't work with Android headless case?

The answer to this question could be one of our missing pieces in the puzzle.

christocracy commented 3 years ago

Is there any documentation/issue that I can read why/how it doesn't work with Android headless case?

As far as I'm concerned, if the Headless event fires, you're free to do anything you wish without restriction.

erluxman commented 3 years ago

Because that doesn't work for the Android headless case.

Use Firebase functions.

Free to do anything? but you mentioned here doing that doesn't work with headless. Do you mean to say headless is not fired in Android?

christocracy commented 3 years ago

but you mentioned here doing that doesn't work with headless

When your headless event fires, there's no limit on what you can do (aside from UI stuff, since there is no UI).

Do you mean to say headless is not fired in Android?

Headless mode is an Android ONLY mechanism. Of course headless events are fired in Android.

erluxman commented 3 years ago

When your headless event fires, there's no limit on what you can do (aside from UI stuff, since there is no UI).

Does that mean uploading to firestore is needs UI? (I don't even had an idea about this)

And I also do not think those lambdas that I was talking in this issue need UI.

I am not getting why the intent of this issue is not possible in the Android Headless case as I can't seem to figure out any involvement of UI on it.

christocracy commented 3 years ago

Does that mean uploading to firestore is needs UI?

No.

And I also do not think those lambdas that I was talking in this issue need UI.

That proposed dart Lambda would no longer exist when the Android app is terminated.

You are completely misunderstanding what I meant by "aside from UI stuff". All I meant is that you cannot do things that access the UI.

christocracy commented 3 years ago

And the dart lambda is pointless since you can simply use Firebase functions.

erluxman commented 3 years ago

That proposed dart Lambda would no longer exist when the Android app is terminated.

I was unaware of this. And now I realize why can't use lambda to receive headless callbacks.

erluxman commented 3 years ago

And the dart lambda is pointless since you can simply use Firebase functions.

It's not completely so as we can limit the traffic/bandwidth/data and processing in fire store and function if we can get it right..