-
Notifications
You must be signed in to change notification settings - Fork 69
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
Implement core architecture to handle push notifications (APNs, UnifiedPush) #1237
Conversation
…/push-notifications
Quick question! There were a couple tasks that I did not do as part of my first implementation of local notifications (such as the ability to check for every logged-in account, and the ability to display mentions and messages). I believe most of these things can be implemented separately from the push notifications feature, but I just wanted to check and see whether you are working on any of these things and/or whether they should wait until this feature is done. |
Sorry for getting back to you so late on this! The changes in this PR moves a lot of logic around, and adjusts a lot of existing logic to be able to handle push notification functionality. I think it might be better to hold off on those changes until this is completed (or at least merged in partially) For instance, a lot of changes were made to the |
… feature/push-notifications
So a bit of an update here - I think this is mostly done at this point (at least for the first iteration of changes). This is a general summary of what has changed:
@micahmo, I've also added you to a new repo which contains the code for the notification server. It's closed off for now since I'd like to get it more fleshed out but you can take a look at that as well if you'd like! As for all of this, I'd like to first get the code merged in if everything looks good. I'm thinking it would be good to merge the code in first to reduce merge conflicts as this is quite a large change, and just disabling the unified push/apns feature outright for now while I continue to refine the notification server logic. Thoughts on this approach? |
Feel free to do a code review on this! I've tried to separate the logic as best as possible so that it's hopefully easier to review 😅 |
@@ -84,60 +84,64 @@ void main() async { | |||
DartPingIOS.register(); | |||
} | |||
|
|||
/// Allows the top-level notification handlers to trigger actions farther down |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this logic was moved to lib/notification/utils/local_notifications.dart
, including the background fetch task.
@@ -1,129 +0,0 @@ | |||
import 'package:flutter/material.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this logic was also moved to lib/notification/utils/local_notifications.dart
and lib/notification/shared/android_notification.dart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very exciting!! I'm totally ok with merging this in to continue testing iteratively.
I did look over the code, and from what I can see, it looks good. Very nicely organized. I did have a couple of questions that weren't obvious (and you can probably answer faster than I can find digging).
- Do we still have logic to handle the app starting due to tapping on a notification?
- It looks like you added multi-account support. On Android (where you can group notifications), are they grouped by account? Will Thunder correctly switch accounts and show the inbox for the right user for the tapped notifications?
- I pulled the code to test, but the "Enable Inbox Notifications" setting is disabled, so I'm not sure how to test. I guess we should at least support existing local notifications while we proceed?
BTW, just a note that I initially got this error when trying to build.
Execution failed for task ':unifiedpush_android:compileDebugJavaWithJavac'.
> Could not find tools.jar. Please check that C:\Program Files\Java\jre-1.8 contains a valid JDK installation.
I'm not sure what the "right" solution is, but I copied Program Files\Android\jdk\jdk-8.0.302.8-hotspot\jdk8u302-b08\lib\tools.jar
to Program Files\Java\jre-1.8\lib
and that worked.
Yup, I believe this located here. Its only enabled for local and unified push since iOS handles the tap: thunder/lib/notification/notifications.dart Lines 44 to 66 in 34893f1
It should be grouped by account! Previously, I think it was one single group for replies, but I tried to separate that into accounts. I think you can probably test it better than I can (I tried it on the emulator and it seemed correct).
Hmm, I have not tried this yet - we would have to do a test to see if this works properly.
Ahh, I set it so that you need to have at least one logged in account to enable the setting. Can you try that and let me know?
Hmm, I encountered this initially as well when I was initially setting it up. I'm also not sure what the best solution here is. I think the unified push package has a dependency on a specific toolchain version in their build.gradle. I'm not too familiar with this so I'm not sure the best way to go about it. |
Thanks for all the responses, everything sounds good! Yes I think we will have to test the multi-account launching. Either we can use the temp account feature, or we can just completely switch the active account to whatever was prompted from the notification.
Oops! I was testing with a different flavor to not mess anything up and forgot to log in. Now it works and I am able to test a bit.
qemu-system-x86_64_BDao11D8Xx.mp4That's all I got for now, but I'll play around! |
…ush, moved notification setting into its own file for oreganization
@micahmo I've updated the code to reflect some of the issues mentioned: 6f8f622
|
Weird, I thought I tested that scenario previously and it seemed to work properly. Let me take a closer look |
Just pushed another commit which should fix the issue with empty notification groups. Let me know if that works! |
For this, it seems like it might take a bit more work to get it running properly. Do you think it might be better for this to be added in a separate PR? If you'd like, you can have a go at it since you might be more familiar with the general flow! |
Thanks for all the quick updates! And yes I can definitely tackle the user issue. 😊 |
Sounds good! Let me know if all the issues you mentioned earlier are fixed. If they are, then I'll go ahead and merge this in to get it out of the way 😅 |
I probably won't be able to test for a little while, so if you want to go ahead and merge now, feel free! |
This looks very exciting! Is there currently a way to test this? |
@codenyte We are still working out the kinks, so it will probably be a little while until this comes to nightly. The only other option would be to build from source. There are some instructions in the README, although I'm not sure if they're completely up to date. |
I tried both building directly using Flutter and with the Docker container. Neither option worked for me, but this might also have to do with my weird setup or my incredible stupidity. |
Not at all, to be fair, the setup instructions are not documented to be completely foolproof, and there are a some assumptions that they make. If you want help building, feel free to reach out in the Matrix chat and send your errors logs. |
Thanks! As @micahmo mentioned, this is probably a little ways away still from being fully functional since there's still a lot of other stuff under-the-hood which would make this functional. For UnifiedPush/Apple Push Notification service (APNs), you need a separate server that polls for new notifications. That server is still being worked on, and I'm trying to make it as simple to self-host as possible (through the use of docker). That would be the ideal scenario, rather than to have you trust me (or anyone else for that matter) with your JWT tokens. |
Right, I forgot that Lemmy doesn't support UP yet (I really hope this gets implemented) |
Pull Request Description
Note: This replaces the previous draft PR created in #1095. I've updated the description to better match the updates.
This is a draft PR which adds the ability to handle push notifications via Apple's push notification service (APNs) and UnifiedPush.
To do this, we have to rely on two separate packages:
push
: handles platform specific implementations for iOS (APNs) and Android (FCM - Firebase Cloud Messaging). This package will only be used to implement iOS APNs. We might add the ability to use FCM in the future if we get enough requests for it.unifiedpush
: handles the UnifiedPush specification on Android. This is limited to Android devices as mentioned here: https://unifiedpush.org/users/faq/#will-unifiedpush-ever-work-on-iosAdditionally, implementing push notifications requires a separate server in order to perform notification polling and sending out push notifications for devices. This is still a WIP.
There is still a lot of work required for this to function properly. I'll add a to-do list here:
While I'm developing the server code, I'll keep it closed-source. I'll most likely make it open-source once I'm done with all the local testing (to ensure that no keys are accidentally committed to the repository)
Issue Being Fixed
Issue Number: #219
Screenshots / Recordings
N/A. Will update when I have more logic completed.
Checklist
semanticLabel
s where applicable for accessibility?