amplify-edge / packages

Flutter Packages
The Unlicense
2 stars 3 forks source link

PACKAGES: Background processes and Notifications #54

Closed winwisely99 closed 4 years ago

winwisely99 commented 4 years ago

why ?

Use case like Chat.

When user has app open, then NATS will do the push over GRPC ( and GRPC-web).

Targets

On mobile we need to check if messages arrived and then make a local notification to wake up the GUI. https://github.com/transistorsoft/flutter_background_geolocation

On Flutter Desktop also. But we can run a Golang service to do that.

On Web

Code

https://github.com/transistorsoft/flutter_background_geolocation

https://github.com/appleboy/gorush

AKushWarrior commented 4 years ago

The basic workflow of this section, as I understand it, is to check for new messages in the background and push a notification if there is any.

(I'm not a NATS/Golang expert, so I don't have much to say about checking for new messages. )

The main issues to solve here are:

  1. Running a background process to check for messages.
  2. Pushing a notification if there are any.

Each platform has a proposed solution.

Mobile

Desktop

Web

AKushWarrior commented 4 years ago

Some basic workflows to encapsulate the proposals above:

Mobile: Once user logs in, start background_fetch, which will push notifications if message has been received.

Desktop: Install a golang service to run in the background along with the app. Run the service to fetch in background and push notifications.

Web: Ask user to subscribe to notifications upon login. If they say yes, start a service worker to do check for messages in background; if a message is found, push a notification using JS interop.

AKushWarrior commented 4 years ago

Some context on Service Workers (for non-JS devs) is available here. There are drawbacks, and in the future we might want to transition to the Push API. However, Safari does not currently support the Push API, so service workers are the most complete solution AFAIK.

winwisely99 commented 4 years ago

I will connect you with the Dev bringup the golang push server !.

Great work.

Let's get busy

winwisely99 commented 4 years ago

For now just fake it from s background isolate so we can see the 3 client types

winwisely99 commented 4 years ago

I have an idea !

We can push message to mobiles using the standard google and apple push services but just say "you have messages". It means that that Apple etc dont see what the message is, and the user open the app and sees their messages in Flutter dedicated messages area.

We can get this working for mobile at V1, and then if we can get background channel for V2, drop using apple and google. The main thing is we have a lowest common denominator via V1 to get going.

The server to do it is there: https://github.com/appleboy/gorush k8 files: https://github.com/appleboy/gorush/tree/master/k8s

winwisely99 commented 4 years ago

@Winwisly100 You can work up LiftBridge to work with this @AKushWarrior You can work up the Flutter Layer. Where to do the work ?

I think that a mod-messages folder in packages makes sense because we will have a dedicated Messages Pane now.

@winwisely112 You can get gorush going and onto k8. The k8s looks old but i think should be good.

https://github.com/appleboy/gorush#run-grpc-service has a GRPC API so we can call it from one MicroService to the gorush MicroService.

AKushWarrior commented 4 years ago

@winwisely99 Just confirming plan...

For mobile, go will push notification directly, so there's no need for a background service ATM.

For desktop, installed Go service will push the notification, so there's nothing there.

For web, we'll still have to roll a service worker or something to notify in the background, BUT it doesn't use the contents, it just says "new message available".

In the 'mod-messages' folder, what am I building with Flutter? Should I outline the messages pane's UI/UX? Or do the platform integrations? Or both?

winwisely99 commented 4 years ago

@AKushWarrior Yep you got all your assertions correct :)

Yes in Packages/mod-message ( singular) your building the client

The golang stuff is not ready ( but i already made issues around it for us to work on )

AKushWarrior commented 4 years ago

@winwisely99 Sorry, just one more thing. Am I using any methods to organize my code (Redux, MobX, BLoC, etc.) ?

winwisely99 commented 4 years ago

We use hive :) it's pretty cool

winwisely99 commented 4 years ago

Let's get liftbridge and gorush into CI. @winwisely112 Then golang coders can write code without needing it installed locally.. Run off the network repo. We use that for all network infrastructure.

Expose public. We don't care about layering of public / private yet. So it's a flat hierarchy for now

Liftbridge.ci.network.getcoyragenow.org Https


Do exactly the same for gorush rush.ci.network.getcouragenow.org

Concept is for liftbridge to fire messages into gorush. These messages will be caught by the flutter client so gorush is our transport for mobiles

The other aspect is to use liftbridge and allow grpc to be the transport and for flutter grpc to catch the events. So grpc is our transport for desktop and web.


@Winwisly100 Need a golang microservice to use it. Can run it locally for now Use packages/mod-messages older I think.

It will call Liftbridge. Liftbridge will then fire the same message into gorush and liftbridge grpc , this denting the same message to mobile , desktop and web.

Put your cli into Tools/messages

winwisely99 commented 4 years ago

@AKushWarrior flutter web produces a service worker automatically these days I think.

For web you will get your messages via grpc liftbridge client pushed to you. So maybe service worker is redundant now.

You are going to have to write code to wrap the grpc dart client that liftbridge code generates for you. https://github.com/liftbridge-io/liftbridge-api

We maintain the forks in my repo ( winwisely99). So it should be there is @Winwisly100 has pushed it.

--

All: for linking from the getcourage repo to my winwisely99 repo I think the easiest way is to use git submodules !! That way in winwisely99 we can maintain all externally forked code. And getcourage can just update it's git submodules to link to the hash of the version in winwisely99. We can use this technique for golang and flutter. The reason is because we can keep getcouragenow repo clean and structured.