-
-
Notifications
You must be signed in to change notification settings - Fork 312
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 new notification features #3724
Implement new notification features #3724
Conversation
4972e4d
to
325dac6
Compare
mobile/src/main/java/org/openhab/habdroid/core/NotificationHelper.kt
Outdated
Show resolved
Hide resolved
mobile/src/full/java/org/openhab/habdroid/core/FcmMessageListenerService.kt
Outdated
Show resolved
Hide resolved
mobile/src/main/java/org/openhab/habdroid/background/BackgroundTasksManager.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: mueller-ma <[email protected]>
Signed-off-by: Danny Baumann <[email protected]>
Signed-off-by: Danny Baumann <[email protected]>
f7735d8
to
311c4cb
Compare
@digitaldan How is |
Also, how exactly is AFAICT, that means we need to pass the reference ID via FCM payload, and need to do client side processing to remove older notifications for that reference ID. |
Also, what about hiding notifications? If the user chooses to hide notifications by tag or reference ID, will the cloud code send |
Signed-off-by: mueller-ma <[email protected]>
0acee54
to
8180992
Compare
Signed-off-by: mueller-ma <[email protected]>
3cc2d45
to
b527c54
Compare
I tried to fix the notification trampoline, but now clicking the button of a |
Since Android 12, the trampoline BroadcastReceiver -> Activity isn't allowed anymore, one must go to the activity from the notification directly. This means for UI actions you need a different |
Its both set as the "collapse_key" as well as is included in the payload , so you should have access to it already. I actually assumed it collapsed delivered notifications, but sounds like you can do that programmatically from the app?
See my comment here, openhab/openhab-addons#16934 (comment)
If the action is a |
It can't, because FCM isn't what posts those notifications, so the app must be responsible for that. Is this different on iOS? |
mobile/src/main/java/org/openhab/habdroid/core/NotificationHandlingReceiver.kt
Outdated
Show resolved
Hide resolved
It is, the collapse key automatically removes / replaces the message with the same collapse id, although i might be able to do that strictly in the app if i wanted to, but this is what Apple recommends. On iOS the app has the opportunity to be called before a non-background notification is posted to the message center, allowing it to mutate the message (so add media for example). For the "hide notifications" feature, we use background messages (no title or message) , which do not get posted to the notification center by default and only the app gets them. This would be the equivalent to android, where the app would then be completely responsible for creating a visual notification based on meta data in the background message. |
Signed-off-by: mueller-ma <[email protected]>
Thinking about the reference-id handling, I think it should be sufficient to just use it instead of persistedId for notification ID generation. This should give us the expected behavior with regards to notification replacement and removal. |
Just FYi this field is only set if the rule or action sets it, so its not guaranteed right now to always be present. I could change that on the cloud server side (so generate a uuid if its not set) if thats a problem. |
Signed-off-by: mueller-ma <[email protected]>
Signed-off-by: mueller-ma <[email protected]>
Signed-off-by: mueller-ma <[email protected]>
Signed-off-by: Danny Baumann <[email protected]>
Signed-off-by: mueller-ma <[email protected]>
This PR is ready to merge from my side. Hiding notifications is tracked in #3686. My debug cert has been added to the Firebase project. When you send me the SHA-1 of your debug cert, I can add it to the app. |
Will do, thanks 👍 Should invoking a notification action hide the notification or not? I tend to say they should, but currently that's not the case.
Do we actually need this endpoint? |
Some other thing I noticed: maniac103@418b6f3 |
Yes, probably it should hide the notification.
It's required that the app sends a "hide this notification" to other app installations of the same user. |
I've added a change for that to my repo, please pick.
Thanks, makes sense, didn't think of that. |
NotificationHelper.cancelNotification() was never called for the summary notification, so the code handling it was misplaced there. Signed-off-by: Danny Baumann <[email protected]>
Signed-off-by: Danny Baumann <[email protected]>
I am currently implementing the Blockly blocks for the notifications. Most of it works already (I'm on beta 3.15.0) but I ran into the following issue
Ever since that with every notification that is received and I click on, this error screens pops up. Even closing the App doesn't fix it and it is therefore broken. I guess I have seen some "wrong" notification which now has created a wrong notification history entry that breaks the App. Any idea how we can debug that? |
What does the app log say? Additionally, what's the JS code which you used for creating that broken notification? |
I connected the mobile phone and locked into logcat with Android studio:
Does that help? How can I access the "applog"? |
At the bottom of the settings page ... but it's just logcat made accessible from the app, so what you posted is sufficient. So the crash says you have a notification without message. How is that even possible? |
First of all, I have now built the project in Android Studio to be able to debug it directly.
I have an idea: I implemented the hide notification as follows: which creates the following code
As the message does not make sense in case of hiding a notification, I kept it empty, so maybe this causes the issue? And guess what, as soon as I sent the above issue the error came up again! I replaced the line with
so now it doesn't crash anymore... |
I guess the actual bug/unexpected behavior is the cloud backend returning messages with type |
Additional information: Let's say I send
Even IF I sent a message with the hide notification everything is omitted except
So even the tag is missing here which is at least surprising. Btw, I would't have expected to receive the action but it actually would say it makes sense even in a hide message to have it: for example a notification could turn on a light and hiding the notification could turn of that light... |
The purpose of |
Keep in mind though, that tags are allowed see https://www.openhab.org/addons/automation/jsscripting/#cloud-notification-actions
|
Oh, right, indeed, tag should be kept. I was mainly referring to the expectation about actions being present. |
The cloud service logs all notification messages. As of a few weeks ago, the API always returns the message payload for notifications, which in this case contains the
This is a helper function that @florian-h05 wrapped around the binding action for the JS library, but i believe if you use the 'hide' function there, its going to internally call |
OK, so this means the
@stefan-hoehn Sounds like |
Tag should not be kept. The JS Scripting docs are unclear at that point, but as the cloud connector add-on only provides methods to hide by tag and other methods to hide by reference id, they cannot be used together when hiding notifications. |
Both done here: #3750 |
One remaining issue: The notification list doesn't load any new notifications beyond the first 20. I guess the issue is caused by |
I'm pretty sure I tried this in the scope of this PR, and it worked fine? The cloud only keeps the latest 50 notifications, are you sure you didn't run into that? The only thing relevant for loading past the first 20 is the |
It didn't work in #3750 anymore, but that's fixed now. |
payload
field