go-textile icon indicating copy to clipboard operation
go-textile copied to clipboard

Push Notifications

Open sanderpick opened this issue 5 years ago • 1 comments

Most real world use cases are gonna require real time notifications. This is just something developers expect to be able to do. There are a bunch of avenues here:

  1. A single app approach is something we've talked about before. Others have too: https://github.com/ipfs/notes/issues/370
  2. A Cafe based approach which requires each dev to dedicate a machine of their own to notifications

Other considerations, by most important:

  1. Users should still be able to dictate where their data is stored and also opt-in to push notifications.
  2. Ideally, every app won't need it's own cafe for notifications. However, typically a server handling iOS and Android notifications only deals with one application. This may be more true w/ iOS, but in any case, switching applications is resource intensive.
  3. Ideally, the push mechanism should simply send a silent notification which wakes up the target app, does any needed data queries, and then finally delivers the content as a local notification.

Given 3., I don't think avenue num. 2 above would work because one app is not able to foreground another app w/o some user action.

  1. and 2. are somewhat contradictory. Here's a proposed solution that's a bit of a compromise between those two considerations:
  • As a start, provide an easy-to-use cafe docker image pre-configured for push notifications. This way, we could federate some cafes that others can use for there own apps (if they trust us), but they could easily spin up their own if they wanted to.
  • Introduce the notion of an application on a cafe, maybe something like textile cafes add --app, which then gives you the option of including iOS/FCM tokens for push notifs. A single cafe could probably handle push notifs for a dozen or so apps by keeping all those connections alive.
  • Introduce a distinction between storage+inboxing and notifications as cafe services. As a client, I can register a cafe for storage and another for push notifs, which I then continue to advertise to the network... "you can find my inbox here, for push notifs go here" etc. This way, a dev could continue to use Textile's federated storage cafes while providing their own for notifications, or vice versa

Libraries:

  • https://github.com/sideshow/apns2
  • https://github.com/appleboy/go-fcm

sanderpick avatar Mar 04 '19 20:03 sanderpick

An alternative to 3.: Encrypt the notification textual content with the account key.This would mean we could in fact go the single-app route, which would be amazing. You'd have to be able to decrypt the message in the app delegate (not familiar with android here). Sound possible @asutula?

sanderpick avatar Mar 10 '19 19:03 sanderpick