novu icon indicating copy to clipboard operation
novu copied to clipboard

🚀 Feature: Novu SDK For Flutter

Open ShashankSMayya opened this issue 1 year ago • 3 comments

🔖 Feature description

Novu SDK for Flutter?

🎤 Why is this feature needed ?

Since Flutter is one of the trending framework for building apps, we would love to see the novu sdk for flutter framework.

✌️ How do you aim to achieve this?

I am really not sure what I can do from my end. We have a project where we are planning to create a notification center for user within the app. I have some ideas of opening a socket to our backend and listen for new notifications and update the ui in realtime but want to know are there any plans on getting novu sdk for flutter. If not any idea how can I implement the feature with sockets using novu?

🔄️ Additional Information

No response

👀 Have you spent some time to check if this feature request has been raised before?

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

None

ShashankSMayya avatar Jun 08 '23 09:06 ShashankSMayya

@ShashankSMayya I'm not into Flutter ecosystem but you may want to search some client library for socket.io (or eventually try to implement your own using regular WS client):

  • https://github.com/rikulo/socket.io-client-dart
  • https://docs.flutter.dev/cookbook/networking/web-sockets

Widget flow:

  1. Client must initialize session with HTTP request
POST 'https://api.novu.co/v1/widgets/session/initialize' 
{
    "applicationIdentifier": "<APP ID>",
    "subscriberId": "<SUBSCRIBER ID>",
    "hmacHash": null
}

As response you will get JSON with data.token - you will need it to authorize ws connection

  1. After initialization you can init socket.io socket with query { "token": "token from previous step" }

  2. Now you can listen for events like:

  • unseen_count_changed
  • unread_count_changed
  • notification_received
  1. To get initial data (and historical as user for example scrolls) for notification center use HTTP calls:
  • GET https://api.novu.co/v1/widgets/notifications/feed?page=0 - for messages
  • GET https://api.novu.co/v1/widgets/notifications/unseen?limit=100 - for unseen number

Use Bearer authorization with token obtained from first step

@scopsy Can you confirm how it works and eventually provide more details? (: I think we need better documentation for custom client-side flows.

michaldziuba03 avatar Jun 08 '23 15:06 michaldziuba03

@michaldziuba03 this is exactly how it works, you nailed it! :)

scopsy avatar Jun 11 '23 10:06 scopsy

Are there any more recent plans for a flutter client sdk? We are evaluating Novu vs Courier and it seems this is something that could be a big win for Courier at the moment.

flodaniel avatar Mar 08 '24 18:03 flodaniel