Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add iOS support for app-icon shortcuts using UIKit system icon types

Barnabas51e08ee8ccd0
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index acccc024..3b724a22 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -97,5 +97,40 @@
<string>Absorb needs access to your photo library to save or select images.</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
+ <key>UIApplicationShortcutItems</key>
+ <array>
+ <dict>
+ <key>UIApplicationShortcutItemType</key>
+ <string>continue_listening</string>
+ <key>UIApplicationShortcutItemTitle</key>
+ <string>Play</string>
+ <key>UIApplicationShortcutItemIconType</key>
+ <string>UIApplicationShortcutIconTypePlay</string>
+ </dict>
+ <dict>
+ <key>UIApplicationShortcutItemType</key>
+ <string>open_search</string>
+ <key>UIApplicationShortcutItemTitle</key>
+ <string>Search</string>
+ <key>UIApplicationShortcutItemIconType</key>
+ <string>UIApplicationShortcutIconTypeSearch</string>
+ </dict>
+ <dict>
+ <key>UIApplicationShortcutItemType</key>
+ <string>open_downloads</string>
+ <key>UIApplicationShortcutItemTitle</key>
+ <string>Downloads</string>
+ <key>UIApplicationShortcutItemIconType</key>
+ <string>UIApplicationShortcutIconTypeCloud</string>
+ </dict>
+ <dict>
+ <key>UIApplicationShortcutItemType</key>
+ <string>open_bookmarks</string>
+ <key>UIApplicationShortcutItemTitle</key>
+ <string>Bookmarks</string>
+ <key>UIApplicationShortcutItemIconType</key>
+ <string>UIApplicationShortcutIconTypeBookmark</string>
+ </dict>
+ </array>
</dict>
</plist>
diff --git a/lib/main.dart b/lib/main.dart
index 5a70f181..5834e05a 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -494,11 +494,14 @@ class _AuthGateState extends State<AuthGate> {
Future.microtask(() => AndroidAutoService().refresh());
// Initialize homescreen widget
await HomeWidgetService().init();
- // App-icon long-press shortcuts (Continue Listening / Downloads).
- // Depends on AudioPlayerService + HomeWidgetService so they're ready
- // when the shortcut handler fires.
- await QuickActionsService().init();
}
+ // App-icon long-press shortcuts. On Android the service registers
+ // dynamic shortcuts + handler; on iOS it only wires the handler since
+ // shortcut items themselves are declared statically in Info.plist
+ // (so we get real UIKit system icon types like `.play`, `.search`).
+ // Depends on AudioPlayerService + HomeWidgetService so they're ready
+ // when the shortcut handler fires.
+ await QuickActionsService().init();
} catch (e) {
debugPrint('[Init] Service init failed: $e');
}
diff --git a/lib/services/quick_actions_service.dart b/lib/services/quick_actions_service.dart
index 8d029f53..2bc67d35 100644
--- a/lib/services/quick_actions_service.dart
+++ b/lib/services/quick_actions_service.dart
@@ -1,3 +1,5 @@
+import 'dart:io';
+
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:quick_actions/quick_actions.dart';
@@ -51,6 +53,13 @@ class QuickActionsService {
}
});
+ // iOS relies on static UIApplicationShortcutItems entries in Info.plist
+ // so it can use UIKit system icon types (.play, .search, .cloud, .bookmark)
+ // without bundling any image assets. The quick_actions_ios plugin's
+ // setShortcutItems only supports templateImageName (bundled PNGs), so
+ // calling it here would replace our nice system icons with nothing.
+ if (!Platform.isAndroid) return;
+
try {
await _quickActions.setShortcutItems(const <ShortcutItem>[
ShortcutItem(