-
Notifications
You must be signed in to change notification settings - Fork 329
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
Update notification and permission handling #274
Conversation
ee7c7d3
to
216d3fa
Compare
2cdeaa3
to
eeda6bb
Compare
e5f29ea
to
709d0de
Compare
9d0fec6
to
be9d82f
Compare
} | ||
val request = UNNotificationRequest.requestWithIdentifier(notificationId, content, trigger) | ||
notificationCenter.addNotificationRequest(request) { error: NSError? -> | ||
// TODO use logger |
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 a TODO for all the println
calls added here and later. Please ignore these for now, I created #285 to fix this in a follow-up PR (to not add even more changes within this one).
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.
That PR is already here: #286
if (items.isNotEmpty() && firstLiveIndex != -1) { | ||
LaunchedEffect(Unit) { | ||
listState.scrollToItem(firstLiveIndex) | ||
} | ||
} |
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.
Quick random fix: scroll to current time in schedule when first loaded
be9d82f
to
56453ad
Compare
message: String | ||
): Unit = | ||
js( | ||
"""{ |
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.
Could we make external declarations for this instead or check if they are in the browser dependency? I really want to avoid string js code
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.
I'll see if this can be moved to the JS side easily, but this is something I moved over from the old implementation as-is. I'd also be happy to just leave it and not touch it, since it works :D
|
||
@OptIn(ExperimentalComposeUiApi::class) | ||
fun main() { | ||
initCoil() | ||
CanvasBasedWindow { | ||
App(ApplicationContext()) | ||
App(platformModule = module { |
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.
we may have last block parameter outside of the ()
, so it can be a bit more readable
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.
Doesn't work here as we're also calling the module
function, but I'd also avoid it either way because it would look confusing in Compose code
suspend fun requestPermission(): Boolean | ||
|
||
fun post( | ||
notificationId: String, |
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.
It would be nice to use value class NotificationId
here, similar to other places.
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.
We need to serialize it into an intent at some point on Android, and pass it to JS for interop, I don't want to complicate its type for now
private const val EXTRA_MESSAGE = "message" | ||
private const val EXTRA_NOTIFICATION_ID = "notificationId" | ||
private const val EXTRA_ICON_ID = "iconId" | ||
private const val NOTIFICATION_CHANNEL_ID = "channel_all_notifications" |
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.
Should we introduce separate channels for different notification types (session alerts vs news)?
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.
Not without putting in a lot more work for managing these channels. The ideal setup for Android users would probably be to use 3 different notification channels and not have in-app settings for notification categories at all, only a button that sends them to the system settings where they can configure each channel. But it's a bunch of extra work just for the one platform, so not critical for the time being.
(We can't read or change the state of notification channels from the app, so we can't sync our own toggles to what the user sets on the channels in settings.)
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.
On the bright side, we'll bump the minimum API to 26 on the icons PR, which is where notification channels were introduced, so that eliminates a whole problem where on 24-25 we'd have to have the in-app switcher instead anyway.
0a80097
to
818db79
Compare
Updates the notification system (and related permission handling) to some new APIs, still implemented with separate native APIs on each platform, as no suitable KMP library was found that covered our use cases (including scheduled notifications).
Makes notification handling depend on
TimeProvider
as well, allowing tests of notifications with fake time values and sped up clocks within the app.