-
Notifications
You must be signed in to change notification settings - Fork 9
feat: push notification #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
4ff8441 to
52b4073
Compare
Merged
1 task
This was referenced Mar 28, 2025
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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