holochain / holochain/android-service-runtime

Emit notifications on behalf of client apps

Open
#20 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
4
Forks
2
Avg merge
1d 5h
Merged PRs (30d)
3

Description

AC:

Storing the signal handler in the runtime state:
- Add a [Foreign trait](https://mozilla.github.io/uniffi-rs/0.29/foreign_traits.html) to runtime & runtime-ffi called `NotificationHandler` with one function `on_notification_signal(Fn(Notification))`.
- In runtime crate, add a parameter `notification_signal_handler: Fn(Notification)` in the `Runtime` struct state
- In the runtime & runtime ffi crates, modify the `new` function to also take a parameter `notification_signal_handler: Fn(Notification)`, store that value in the state

Listening for signals:
- The runtime will need to listen for signals from all apps. I'm not sure if this can be done via the conductor handle directly, or if it needs to connect to an app websocket for all apps. Either way the implementation would be roughly the same:
- Call `on_signal` and pass in a closure
- In the closure we attempt to decode the signal into a Notification
- If successful, we call `self.notification_signal_handler(notification)`

Defining the `SignalHandler` foreign trait implementation in kotlin:
- In the `HolochainService`, add a `handleRuntimeNotificationSignal` function, which takes a `NotificationFfi`, and generates the notification. Pass this function into the `runtime.new()` call

Checking if the received signal should create a notification:
- In the `handleRuntimeNotificationSignal` function, creates a notification, configured by the fields of the `Notification` data
- The `Notification` signal has the following structure:
```rust
struct Intent {
action: String,
package_name: String,
class_name: String,
}

enum Priority {
Low,
Medium,
High
}

struct Notification {
priority: Priority,
title: String,
text_short: Option,
text_long: Option,

// Bytes of an icon bitmap
icon: Option>,

// Intent to create when the notification is tapped
tap_intent: Option,
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.