status-im / status

0 stars 1 forks source link

In-app Push Notifications for transactions #5

Open iurimatias opened 3 years ago

iurimatias commented 3 years ago

(originally in https://github.com/status-im/status-react/issues/11101)

As a user, I want to receive notification for actions that happen in the app which are not in my current focus, so thus I can instantly react and switch to the new actions.

Add push notification to specific transactions and accounts.

This change will also include the migration to new flow for building the notifications inside status go. Initially pushing only the transaction notifications.

Status go will keep a service listening to new messages (later) and transactions (now). When they happen, inside status go we build the notification and send it to the app using the new signal notification.

{
"id": "A unique notification id",
"title": "Notification title",
"body": "Notification message", (Could be an object if we want to build i18n strings during handling of signal)
"platform": "Name of platform if the notification is platform-specific",
"category": "category name, to show actions like reply, (Could be also defined on the build layer based on body fields)",
"image": "Url to show the image if present,"
"dl": "deep link to app screen",
}

On Android, a thin overlay over native notification module will keep a background service and show local notifications.

On iOs, we can also write a thin overlay in native code, or we can use directly ClojureScript as the OS does not keep our app in the background for a long time.

The status go knows the current-chat-id and can cancel the sending of specific notification if the user is currently in the chat.

The watching of transactions can work similarly to the current implementation https://github.com/status-im/status-react/blob/08ff2edb0be798e5499c8c90024dd01b6d55865b/src/status_im/ethereum/transactions/core.cljs#L88

Status go will hold also all the state values (subscribed/unsubscribed) for specific notification types and chats/addresses. One way to keep them as a table of [type[enum], topic[object], preference[enum ]]

Example: [chat,{(chat-type) private, chat-id, (message-type)mention},subscribed] ["chat", {"private", "0x0...", "new-message"}, subscribed]

Note that currently, there is an active task to improve watching transactions #9987

*All the technical details are just an opinion and not a specification

iurimatias commented 3 years ago

https://github.com/status-im/status-go/pull/2026

hesterbruikman commented 3 years ago

@iurimatias with #2026 merged, can this issue be closed?