☰ Docs menu · Computers (macOS, Windows, Linux)
Computers (macOS, Windows, Linux)
Push notifications and in-app messages for Flutter apps on macOS, Windows and Linux, from the same project as your phone apps. Optional tray and start with the computer.
Windows notifications, the Linux desktop's notifications and macOS Notification Center, with buttons
Shown as soon as you publish or change them in the Console
The same API key, users and topics as your phone apps
Keep running in the tray when the window closes, and start with the computer
Pushes sent while the computer was off arrive when the app runs again
The Console shows deliveries and clicks for computers like for phones
The same Abrova user token as Sync, Chat and the phone SDKs, straight from Abrova Auth
Computers report their own errors to the Console, like phones
Before you begin#
- An Abrova project with Push turned on, and its public API key (
ab_live_...), from Abrova Console. Pick macOS, Windows or Linux in Project settings › Platforms. - A way to sign your users in: Abrova Auth gives the user token Push needs, or your server mints it (Signed user tokens).
- Flutter 3.44 or later.
- Windows: to build, Visual Studio (or its Build Tools) with Desktop development with C++ and the C++ ATL component.
- Linux: to build,
sudo apt-get install libayatana-appindicator3-dev. Users needlibayatana-appindicator3-1for the tray icon (add it to your.debdependencies). - macOS: allow outgoing connections:
com.apple.security.network.clientset totrueinmacos/Runner/DebugProfile.entitlementsandRelease.entitlements.
For Android, iOS and the web, use the Flutter SDK.
Step 1: Installation#
Add the package from Abrova Center to pubspec.yaml:
dependencies:
abrova_push_desktop:
hosted: https://center.abrova.ir/api/packages/abrova/pub
version: ^0.1.3Then run flutter pub get.
Step 2: Register the computer#
import 'package:abrova_auth/abrova_auth.dart';
import 'package:abrova_push_desktop/abrova_push_desktop.dart';
Future<void> main(List<String> args) async {
WidgetsFlutterBinding.ensureInitialized();
await AbrovaAuth.initialize('ab_live_...');
await AbrovaPushDesktop.init(AbrovaPushDesktopConfig(
apiKey: 'ab_live_...', // the same key as your phone apps
appIdentifier: 'com.example.app',
tokenProvider: AbrovaAuth.instance.tokenProvider, // the signed-in user's token
));
await AbrovaPushDesktop.register(userId: AbrovaAuth.instance.currentUser?.id);
AbrovaPushDesktop.onMessage.listen((message) {
print('${message.title}: ${message.body} ${message.data}');
});
AbrovaPushDesktop.onNotificationTapped.listen((message) {
// Open the screen for message.deepLink or message.data
});
runApp(const MyApp());
}Use the API key only. The server secret belongs on your server, which sends the pushes; never put it in an app.
register is safe at every start: the computer keeps its install id. With userId, a push to that user reaches all their phones and computers at once.
Signed user tokens#
The API key in your app is public, so a user id alone does not prove who the user is. The tokenProvider does: it returns the signed-in user's Abrova user token, the same token, and the same function, you give Abrova Sync, Chat and the phone Push SDK. With Abrova Auth it is AbrovaAuth.instance.tokenProvider; without it, a function that asks your server, which gets the token from https://auth.abrova.ir/users/token with the server secret.
Registering with a userId, or calling setUserId, needs it: when your project requires signed user tokens, the server answers 401 token_required without one.
The SDK waits for the token before each request, asks again once if the server says it expired, and sends the request without one if the provider fails or takes longer than 10 seconds.
// Set or change it later, for example when your sign-in is ready: AbrovaPushDesktop.setTokenProvider(AbrovaAuth.instance.tokenProvider); // Or hand over a token you fetched yourself (call again when you refresh it): AbrovaPushDesktop.setUserToken(token); // Refused or expired token, or the provider failed: send the user to sign in. AbrovaPushDesktop.onAuthError((error) => print(error.code));
error.code | Meaning |
|---|---|
token_required | The project requires a user token and none was sent |
token_invalid | The server did not accept the token |
token_expired | The token expired and no fresh one could be obtained |
token_mismatch | The userId is not the user the token was issued for |
token_provider_failed | Your provider threw or did not answer in 10 seconds |
Step 3: Send a push#
Send from the Console (Push › Send) or from your server, exactly as to phones: to the user, to topics, to a segment, or to everyone. In segments you can pick computers with the Platform rule (macOS, Windows, Linux).
Notifications and permission#
On macOS the SDK asks the user to allow notifications during init (once, without waiting for the answer). To ask at a better moment, set askNotificationPermission: false and call AbrovaPushDesktop.requestNotificationPermission() yourself. Windows and Linux need no permission.
final permission = await AbrovaPushDesktop.notificationPermission(); // allowed, notAllowed (macOS: ask, or point the user to System Settings › Notifications), notNeeded
| Option | Default | |
|---|---|---|
showNotifications | true | Show a system notification for each push that is not silent |
showNotificationsWhileFocused | true | Also when your window is in front (onMessage fires either way) |
askNotificationPermission | true | macOS: ask to allow notifications during init |
appName | the app's name | The name on notifications |
windowsAppUserModelId | appIdentifier | Windows: the id notifications are grouped under |
windowsNotificationGuid | from appIdentifier | Windows: keep it the same in every version of your app |
tokenProvider | none | The signed-in user's Abrova user token (Signed user tokens) |
sendDiagnostics | true | Send the SDK's own error counts with its requests (Connection state and errors) |
A click opens your app, fires onNotificationTapped and is counted as opened in the Console; a button click carries the button's id.
Notifications turned off#
macOS asks the user once. If they say no, or later turn notifications off in System Settings, pushes still arrive (onMessage fires) but no banner shows, and no app can switch them back on. The SDK tells you, so you can show a hint with a button:
// macOS: the user turned notifications off (System Settings). The app can't turn them back on, so show a hint:
AbrovaPushDesktop.onNotificationPermissionChanged.listen((p) {
if (p == AbrovaPushNotificationPermission.notAllowed) {
// e.g. a bar: "Notifications are off" [Turn on] → opens this app's notification settings
showNotificationsOffBar(onTurnOn: AbrovaPushDesktop.openNotificationSettings);
}
});openNotificationSettings() opens this app's page in System Settings › Notifications (macOS) or Settings › Notifications (Windows). Windows and Linux report notNeeded. On macOS the SDK also tells Abrova, so the Console marks the computer Notifications off and says why its messages were not seen.
Background mode (tray and start with the computer)#
By default the app receives pushes while it runs. To keep receiving them after the user closes the window, turn on background mode, as chat apps do:
await AbrovaPushDesktop.enableBackgroundMode( trayIconPath: Platform.isWindows ? 'assets/tray.ico' : 'assets/tray.png', trayIconIsTemplate: true, // macOS: a one-colour icon that follows the menu bar's light or dark look keepRunningInTray: true, // closing the window hides it to the tray launchAtStartup: true, // start with the computer… startHidden: true, // …in the tray, without opening the window openLabel: 'Open', quitLabel: 'Quit', ); if (AbrovaPushDesktop.startedHidden(args)) await AbrovaPushDesktop.hideWindow();
The SDK does the tray icon and its menu, hides the window instead of closing it, and adds the app to the computer's start-up list (Windows, macOS and Linux each in their own way). You only give it your icon (add it to your Flutter assets) and the menu's words in your app's language.
The tray menu opens the window or quits the app. When the app started at login in the tray, AbrovaPushDesktop.startedHidden(args) is true (pass main's args): call AbrovaPushDesktop.hideWindow() so the window stays hidden. AbrovaPushDesktop.showWindow() brings it back. Give your users a setting such as "Show notifications when the app is closed", and call AbrovaPushDesktop.setLaunchAtStartup(false) when they turn it off.
macOS: an app quits when its last window closes unless its AppDelegate says otherwise. For background mode, return false in macos/Runner/AppDelegate.swift, and bring the window back when the Dock icon is clicked:
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return false
}
override func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
if !flag { sender.windows.first?.makeKeyAndOrderFront(self) }
return true
}When the app is fully quit, nothing runs on the computer: pushes wait on the server and arrive the next time the app starts.
In-app messages#
Create them in the Console (Push › In-app). On computers they appear when the app opens, when a session starts, or on your own event, with the same rules as on phones. When you publish or change one, running apps show it within a minute.
final navigatorKey = GlobalKey<NavigatorState>(); // the one your MaterialApp uses
AbrovaPushDesktop.showInAppMessages(
navigatorKey: navigatorKey,
onButtonTap: (context, message, button) {
// url buttons open in the browser by themselves; route deep links and handle custom values here
if (button.action == 'deep_link') Navigator.of(context).pushNamed(button.value!);
},
);
await AbrovaPushDesktop.triggerInAppEvent('opened_settings');The SDK shows each message in your app's window and in your app's language (the Console's "Add language"): modal, banner (top or bottom), full screen or card, with the image, colours and up to two buttons from the Console, and records impressions, clicks and dismissals. Change the look with theme: AbrovaPushInAppTheme(...), or draw a type yourself with builders: AbrovaPushInAppBuilders(modal: ...).
To draw every message yourself instead, skip showInAppMessages, listen to onInAppMessage, pick the text with message.contentFor(languageTag) and call recordInApp(message, 'button_click', buttonId: ...) / 'dismiss'.
On computers an app may run for days in the tray, so the SDK decides what "opening" means:
| Console trigger | Fires on a computer when |
|---|---|
| App open | the app starts, or its window comes back from the tray (also by a notification click) |
| Session start | the app starts, or the user comes back after sessionTimeout away (default 30 minutes: window hidden, minimised or behind other apps) |
Switching between windows alone is neither. minSessionCount counts these sessions.
Users and topics#
await AbrovaPushDesktop.setUserId('user-42');
await AbrovaPushDesktop.clearUserId();
await AbrovaPushDesktop.subscribeTopic('news');
await AbrovaPushDesktop.unsubscribeTopic('news');Connection state and errors#
AbrovaPushDesktop.onConnectionState.listen((state) => print(state)); // connecting, connected, disconnected AbrovaPushDesktop.onError.listen((error) => print(error));
The SDK reconnects by itself and catches up on pushes it missed. Call AbrovaPushDesktop.reconnectNow() to try at once, for example when your window comes to the front.
Like the phone SDKs, the SDK counts its own errors (connection, registration, topics) and sends the counts with its next request, so you see them in the Console next to your phones. It sends only error numbers and short fixed reasons such as timeout or http503: never a message, user or device detail. Turn it off with sendDiagnostics: false.
Common mistakes#
- The server secret in the app. Apps use the API key only; the server secret stays on your server.
401 token_requiredatregister. You passed auserIdwithout atokenProvider. Pass the Auth SDK'stokenProvider(or your server's) in the config.- macOS: no connection. The app is missing
com.apple.security.network.clientin its entitlements. - Windows: the build fails with
atlbase.h. Add the C++ ATL component in the Visual Studio Installer. - Linux: no tray icon. The computer is missing
libayatana-appindicator3-1. - macOS: closing the window quits the app.
applicationShouldTerminateAfterLastWindowClosedstill returnstrueinAppDelegate.swift; returnfalse(Background mode). - Expecting notifications after the app is quit. Nothing runs then; turn on background mode so the app stays in the tray, or pushes arrive at the next start.
- macOS: delivered, but no banner. Notifications are off for the app in System Settings; see Notifications turned off.
- A new
windowsNotificationGuidin a new version. Keep it the same, or Windows treats the update as another app.
Billing#
Each computer that connects in a month counts as one device, the same as a phone.
Last updated: 20 Nov 2026