Update UnifiedPush library
Content
Update UnifiedPush library
Motivation and context
Be up to date and let Renovate handle this in the future.
We will also benefit from improvement from the library, in particular the support for RAISE_TO_FOREGROUND added in https://github.com/UnifiedPush/android-connector/commit/7438c52c3f0ef2edba4c908c2cf796297aeb888c .
Screenshots / GIFs
Tests
- Ensure that UnifiedPush notification are still working (still under test on my side)
Tested devices
- [ ] Physical
- [x] Emulator
- OS version(s):
Checklist
- [ ] Changes have been tested on an Android device or Android emulator with API 24
- [ ] UI change has been tested on both light and dark themes
- [ ] Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
- [ ] Pull request is based on the develop branch
- [ ] Pull request title will be used in the release note, it clearly define what will change for the user
- [ ] Pull request includes screenshots or videos if containing UI changes
- [ ] You've made a self review of your PR
:iphone: Scan the QR code below to install the build (arm64 only) for this PR.
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/3qTYjg
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 80.40%. Comparing base (
b926f5f) to head (beb7297). Report is 4 commits behind head on develop.
Additional details and impacted files
@@ Coverage Diff @@
## develop #4358 +/- ##
===========================================
- Coverage 80.40% 80.40% -0.01%
===========================================
Files 2142 2142
Lines 56642 56642
Branches 7081 7081
===========================================
- Hits 45545 45544 -1
Misses 8679 8679
- Partials 2418 2419 +1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
I am testing that the upgrade do not break anything, and sadly I do not receive anymore push from ntfy, even when not using a matrix.org account.
The troubleshoot fails at the "Test push loopback":
Logs:
POST https://ntfy.sh/_matrix/push/v1/notify
{"notification":{"event_id":"$THIS_IS_A_FAKE_EVENT_ID","room_id":"!room:domain","devices":[{"app_id":"im.vector.app.android","pushkey":"https://ntfy.sh/upMQ1D9W3MlzAD?up=1"}]}}
<-- 507 https://ntfy.sh/_matrix/push/v1/notify
{"code":50701,"http":507,"error":"cannot publish to UnifiedPush topic without previously active subscriber"}
Seems related: https://github.com/binwiederhier/ntfy/issues/649
This may be because your ntfy didn't have any registration when it has received elemen-x request. And ntfy is a bit buggy during this state. This would be fixed with https://github.com/binwiederhier/ntfy-android/pull/97
You can try Sunup, it will use the default gateway (matrix.gateway.unifiedpush.org) or create a first registration on ntfy before doing the tests
Testing again this morning, now the troubleshoot tests are OK, but I still do not receive push from the homeserver. When switching to Firebase it's working.
MSC4173 would probably help here. The server may have rejected the push key due to the previous 507 error
You can try:
- to remove the registration from ntfy (be sure to give it unrestricted background use, because of the bug quoted above) and try again
- or try sunup
I selfhost both ntfy and synapse
I built ntfy-android with https://github.com/binwiederhier/ntfy-android/pull/97 and https://github.com/binwiederhier/ntfy-android/pull/98 I built Element X with this patch based on the latest tag
- Upon installing I ran the the troubleshooting with my existing setup and it passed without issues as before
- Closed both apps from the foreground and sent a message, received instantly.
- Force closed Element X and cleared it's cache
- Sent another message, got the notification instantly too.
- Killed Element X and removed the topic from the ntfy android app
- Tried sending another message and obviously got nothing, but synapse logs still claimed to be trying to sending them to ntfy server (I guess this is a synapse/nfty server issue who are not communicating deletions and out of scope here)
- Opened Element X again and it automatically registered a new topic without any input.
- Run a troubleshoot without errores.
- Killed Element X again
- Sent another message, received without issues.
Is there anything else missing or that I can test ? Been running the patch for a month without issues on notification receipts so on my clueless knowledge it seems ready to go.
The current changes don't seem to work reliably on my end, sadly (element.io account).
- I switched Firebase to NTFY, it didn't seem to take effect until I restarted the app.
- Once restarted, I sent a few messages again from another account and I got one quite fast and the rest either were delayed a long time or didn't arrive at all.
- After a while no new notifications were received.
This device is charging and with the screen on, so Doze should not apply. The server is ntfy.sh, maybe I should change that.
The logs display a couple of timeouts, but otherwise just something like:
[https://ntfy.sh/xxxxxxl] Connection is active (failed=false, callCanceled=false, jobActive=true, serviceStarted=true
When a timeout happens, the service reconnects but no new notifications arrive. I might try with the changes proposed by @Eskuero above.
The current changes don't seem to work reliably on my end, sadly (element.io account).
Can you try with Sunup, or with another ntfy server (eg. https://ntfy.adminforge.de/), and double check that you have allowed background usage without restrictions for ntfy
With Sunup the notifications arrive, but they're severely delayed (30s) and for some reason they appear twice in the list of notifications 😓 .
With NTFY + the alternative server, I had the same problemas as before: some notifications being delayed, most not arriving at all. I also couldn't build a custom version of NTFY with the patches mentioned above, the versions are quite outdated and every time I fix a problem another one appears...
I have the app already built with the patches in my fdroid repo https://repo.fromshado.ws/repo/ https://repo.fromshado.ws/repo/ntfy-android-fdroidrelease-fdroid.apk
If you would rather give another try at building the clean patchfile to apply is also here: https://github.com/Eskuero/nino_samples/tree/master/ntfy-android
And also is true that probably the ntfy.sh instance is putting some ratelimits which might harm testing. If you want I can give you access to my ntfy instance. Ping me at @eskuero:matrix.fromshado.ws
With Sunup the notifications arrive, but they're severely delayed (30s) and for some reason they appear twice in the list of notifications 😓 .
This is probably not the best place to debug setups. There are a lot of reasons why a notification could be delayed (depending on the load on the server, if the client have history to fetch, if it can get the decryption keys, etc.). It also depends on your OS configuration, if it is in doze mode etc. When doing tests, you may figure out that sometimes the web client get its notification after the android client, sometimes the opposite. You 'd see the same thing with FCM too
Can you try with version 3.0.9 ?
Can you try with version 3.0.9 ?
Sure. Is there any bug fixed on the new version that may help with the encountered problem?
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Can you try with version 3.0.9 ?
Sure. Is there any bug fixed on the new version that may help with the encountered problem?
There was a bug that doesn't apply here, sorry for the ping. For the details, PushService can be used to replace the MessagingReceiver, but isn't used here and it didn't work correctly with SDK<33
By the way, what is the encountered problem ? Is it the 507 response ?
It may be better to use a resolutionStrategy than to exclude the transient dependency.
something like
configurations.all {
resolutionStrategy {
force(libs.tink)
dependencySubstitution {
substitute module('com.google.crypto.tink:tink-android') using module(libs.tink)
}
}
}
Just for the record, I was able to get reliable push notifications working in NTFY by doing:
- Deleting every single topic in ntfy.
- Changing the push server to ntfy.adminforge.de.
- Switching to firebase, then back to ntfy in the notification settings.
- Checking the new server is used in ntfy (a new topic is created with the server name being part of it).
I have battery optimizations disabled on EXA, btw. With it enabled, notifications sometimes take some time to arrive.
Thanks for the commit @jmartinesp !
We have decided to merge this PR and let users play with the nightly (that can be joined at https://appdistribution.firebase.dev/i/7de2dbc61e7fb2a6) and report any issue with UnifiedPush / ntfy.
If we got issues, we will revert this PR before the next release.
| Warnings | |
|---|---|
| :warning: |
gradle/libs.versions.toml#L23 - A newer version of androidx.compose:compose-bom than 2025.04.00 is available: 2025.05.01 |
| :warning: |
gradle/libs.versions.toml#L40 - A newer version of io.coil-kt.coil3:coil-test than 3.1.0 is available: 3.2.0 |
| :warning: |
gradle/libs.versions.toml#L42 - A newer version of com.bumble.appyx:testing-junit4 than 1.7.0 is available: 1.7.1 |
| :warning: |
gradle/libs.versions.toml#L43 - A newer version of app.cash.sqldelight:sqlite-driver than 2.0.2 is available: 2.1.0 |
| :warning: |
gradle/libs.versions.toml#L45 - A newer version of me.saket.telephoto:zoomable-image-coil than 0.15.1 is available: 0.16.0 |
| :warning: |
gradle/libs.versions.toml#L189 - The native library |
| :warning: |
gradle/libs.versions.toml#L210 - A newer version of io.element.android:element-call-embedded than 0.9.0 is available: 0.11.1 |
Generated by :no_entry_sign: dangerJS against beb7297721797bc97470396aac26036d12d37c5b