fix: restore built-in push notifications on Android (#2055)

<!-- Please read
https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before
submitting your pull request -->

### Description

<!-- Please include a summary of the change. Please also include
relevant motivation and context. List any dependencies that are required
for this change. -->

Fixes #

#### Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings

### AI disclosure:

- [ ] Partially AI assisted (clarify which code was AI assisted and
briefly explain what it does).
- [ ] Fully AI generated (explain what all the generated code does in
moderate detail).

<!-- Write any explanation required here, but do not generate the
explanation using AI!! You must prove you understand what the code in
this PR does. -->
This commit is contained in:
Erwan Leboucher authored and GitHub committed 2026-09-06 23:14:16 +02:00
commit 9e48d53476
5 files changed
+80 -4

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
default: patch
---
Fix built-in push activation on Android and preserve custom push servers after restarting.
+1 -1
View File
@@ -8325,7 +8325,7 @@ dependencies = [
[[package]]
name = "tauri-plugin-notifications"
version = "0.5.0"
source = "git+https://github.com/SableClient/tauri-plugin-notifications.git?rev=a837cd9bb87fe85ecb2a8061e6ec7e8933823dd0#a837cd9bb87fe85ecb2a8061e6ec7e8933823dd0"
source = "git+https://github.com/SableClient/tauri-plugin-notifications.git?rev=f2f320f12a5904ece6d648ce551f9d56bb4a9175#f2f320f12a5904ece6d648ce551f9d56bb4a9175"
dependencies = [
"log",
"notify-rust",
+3 -3
View File
@@ -110,12 +110,12 @@ windows = { version = "0.62", features = [
tauri-plugin-single-instance = { version = "2.4.3", features = ["deep-link"] }
[target.'cfg(any(windows, target_os = "linux"))'.dependencies]
tauri-plugin-notifications = { git = "https://github.com/SableClient/tauri-plugin-notifications.git", rev = "a837cd9bb87fe85ecb2a8061e6ec7e8933823dd0" }
tauri-plugin-notifications = { git = "https://github.com/SableClient/tauri-plugin-notifications.git", rev = "f2f320f12a5904ece6d648ce551f9d56bb4a9175" }
# default-features = false drops notify-rust so macOS uses the native
# UNUserNotificationCenter backend (needs a signed .app to deliver).
[target.'cfg(target_os = "macos")'.dependencies]
tauri-plugin-notifications = { git = "https://github.com/SableClient/tauri-plugin-notifications.git", rev = "a837cd9bb87fe85ecb2a8061e6ec7e8933823dd0", default-features = false }
tauri-plugin-notifications = { git = "https://github.com/SableClient/tauri-plugin-notifications.git", rev = "f2f320f12a5904ece6d648ce551f9d56bb4a9175", default-features = false }
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-updater = { version = "2", optional = true }
@@ -139,7 +139,7 @@ libloading = "0.9"
zbus = "5"
[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
tauri-plugin-notifications = { git = "https://github.com/SableClient/tauri-plugin-notifications.git", rev = "a837cd9bb87fe85ecb2a8061e6ec7e8933823dd0", features = [
tauri-plugin-notifications = { git = "https://github.com/SableClient/tauri-plugin-notifications.git", rev = "f2f320f12a5904ece6d648ce551f9d56bb4a9175", features = [
"push-notifications",
] }
tauri-plugin-edge-to-edge = { git = "https://github.com/SableClient/tauri-plugin-edge-to-edge.git", rev = "33c6116c27be28c06df5a9d02231ecc5fdeb93c5" }
@@ -0,0 +1,65 @@
import { render, waitFor } from '@testing-library/react';
import { beforeEach, expect, it, vi } from 'vitest';
import { NotificationTransportRuntimeFeature } from './NotificationTransportRuntimeFeature';
const mocks = vi.hoisted(() => ({
enable: vi.fn<(...args: unknown[]) => Promise<{ endpoint: string }>>(),
config: { pushTransport: { unifiedPushEmbeddedServerUrl: 'https://push.example' } },
overrides: {} as { unifiedPushEmbeddedServerUrl?: string },
mx: {},
setSetting: vi.fn<() => void>(),
}));
vi.mock('@tauri-apps/api/core', () => ({ isTauri: () => true }));
vi.mock('@tauri-apps/plugin-os', () => ({ type: () => 'android' }));
vi.mock('$hooks/useMatrixClient', () => ({ useMatrixClient: () => mocks.mx }));
vi.mock('$hooks/useClientConfig', () => ({ useClientConfig: () => mocks.config }));
vi.mock('$state/hooks/settings', () => ({
useSetting: (_atom: unknown, key: string) => [
(
{
backgroundPushEnabled: true,
backgroundPushProvider: 'unifiedpush',
pushTransportMode: 'unifiedpush',
pushTransportOverride: mocks.overrides,
} as Record<string, unknown>
)[key],
mocks.setSetting,
],
}));
vi.mock('./UnifiedPushNotifications', () => ({
enableUnifiedPush: mocks.enable,
setEncryptedContentAllowed: async () => {},
listenForUnifiedPushMessages: async () => ({ unregister: async () => {} }),
}));
vi.mock('./UnifiedPushTransport', () => ({ isUnifiedPushPermissionGranted: async () => true }));
vi.mock('./NativePushNotifications', () => ({
enableNativePush: async () => {},
isNativePushPermissionGranted: async () => true,
}));
beforeEach(() => {
mocks.enable.mockReset().mockResolvedValue({ endpoint: 'https://push.example/topic' });
mocks.overrides = {};
});
it('keeps the configured built-in server during startup registration', async () => {
render(<NotificationTransportRuntimeFeature />);
await waitFor(() =>
expect(mocks.enable).toHaveBeenCalledWith(
mocks.mx,
expect.objectContaining({ unifiedPushEmbeddedServerUrl: 'https://push.example' })
)
);
});
it('uses the saved built-in server override during startup registration', async () => {
mocks.overrides = { unifiedPushEmbeddedServerUrl: 'https://custom.example' };
render(<NotificationTransportRuntimeFeature />);
await waitFor(() =>
expect(mocks.enable).toHaveBeenCalledWith(
mocks.mx,
expect.objectContaining({ unifiedPushEmbeddedServerUrl: 'https://custom.example' })
)
);
});
@@ -109,6 +109,7 @@ export function NotificationTransportRuntimeFeature() {
const upConfigRef = useRef<{
unifiedPushAppID?: string;
unifiedPushEmbeddedServerUrl?: string;
unifiedPushGatewayUrl?: string;
vapidPublicKey?: string;
webPushAppID?: string;
@@ -119,10 +120,15 @@ export function NotificationTransportRuntimeFeature() {
upConfigRef.current = {
unifiedPushAppID:
pushTransportOverride?.unifiedPushAppID ??
clientConfig.pushTransport?.unifiedPushAppID ??
clientConfig.pushNotificationDetails?.unifiedPushAppID,
unifiedPushGatewayUrl:
pushTransportOverride?.unifiedPushGatewayUrl ??
clientConfig.pushTransport?.unifiedPushGatewayUrl ??
clientConfig.pushNotificationDetails?.unifiedPushGatewayUrl,
unifiedPushEmbeddedServerUrl:
pushTransportOverride?.unifiedPushEmbeddedServerUrl ??
clientConfig.pushTransport?.unifiedPushEmbeddedServerUrl,
vapidPublicKey: clientConfig.pushNotificationDetails?.vapidPublicKey,
webPushAppID: clientConfig.pushNotificationDetails?.webPushAppID,
pushNotifyUrl: clientConfig.pushNotificationDetails?.pushNotifyUrl,