这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@poppingmoon
Copy link
Owner

Implemented push notifications for Android and iOS.

On Android, users can choose an external UnifiedPush distributor app or an embedded FCM distributor.
If you choose the external distributor, notifications from Misskey will be sent directly to the distributor server and the messages will be decrypted inside the app.
Otherwise, if you choose FCM, notifications will first go to Misskey Web Push Proxy for decryption, then they will be sent to the devices via FCM.

On iOS, the process is similar to the FCM method, but the decrypted messages will be delivered through APNs instead.

Fix #284

Moved some initialization processes from `BootState` notifier to the
`_init` method in `Aria` widget.
Also moved the initialization of `RustLib` into the method.
This may shorten the startup duration.
If network request failed, show the error response with `ErrorMessage`
widget.
The `sw/register` endpoint of Misskey is marked `secure` and cannot be
accessed using an access token issued with MiAuth.
This dialog generates an AiScript code that sends the request and
prompts the user to run it on the scratchpad of Misskey Web.
Once the code is executed, the scratchpad shows a dialog with the
response.
Finally, by pasting the response, Aria can indirectly utilise the
endpoint.
Added a page to register to push notifications.
When the switch is enabled, it generates keys that are used to later
decrypt Web Push messages sent from Misskey.
The keys and an endpoint to which Misskey server sends notifications are
then sent.

The endpoint must be unique among all subscriptions.
If a user is on an Android device and chooses an external UnifiedPush
distributor like ntfy, that distributor will provide the endpoint.
In this case, encrypted Web Push messages will be distributed, and Aria
needs to decrypt that within the app, so the keys will be saved on the
device.
If the user doesn't have any distributor apps, chooses the internal
distributor, or is on iOS, the endpoint directs to [Misskey Web Push
Proxy](https://github.com/poppingmoon/misskey-web-push-proxy).
The keys will be sent to the proxy to allow it to decrypt the messages
on the server.
Generation of the endpoint will be implemented in later commits.

After that, the endpoint will be stored on the device for later
unsubscription.
For Android, use [UnifiedPush](https://unifiedpush.org) to get the
target endpoint to which Misskey servers send notifications.
If multiple distributor apps are installed on the user device, shows a
dialog to select one of them.
Added [Android FOSS Embedded FCM Distributor]
(https://codeberg.org/UnifiedPush/android-embedded_fcm_distributor) for
a fallback of UnifiedPush Distributors.
If the user does not have any distributor apps installed, this will be
automatically selected.
Otherwise, it will appear as one of a distributors that the user can
choose.

According to the official documentation, the `getEndpoint` function is
supposed to return an endpoint.
However, for Aria, it has been modified to return an FCM token instead,
since the actual endpoint will be generated on the Flutter side.

The token is prefixed to indicate that the returned value is from the
embedded distributor or from an external distributor.
On the Flutter side, the prefix is removed and the token will be sent to
the proxy to allow it to send notifications via FCM.
Added the `UserIdsNotifier` which saves the `userId` associated with the
account.
This will be used to determine which account the notification was sent
to.

The function to save the id will be called on signing in and subscribing
to push notifications.
This ensures that the id is available when a push notification is
received, even if the user was signed in before this feature was added.
@poppingmoon poppingmoon merged commit cd9d2fe into main Oct 16, 2024
14 checks passed
@poppingmoon poppingmoon deleted the push-notification branch October 16, 2024 12:20
This was referenced Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

push notification

2 participants