ios_system_sound 0.1.1
ios_system_sound: ^0.1.1 copied to clipboard
Playing UI Sound Effects or Invoking Vibration Using System Sound Services on iOS.
iOS System Sound #
Playing UI sound effects or invoking vibration using System Sound Services on iOS.
English | 简体中文
✨ Features #
- 🎛️ Plays every predefined iOS system sound (
SystemSoundID): mail, SMS, alerts, key presses, camera, recording, DTMF, headset, ... - 📳 Triggers vibration through
kSystemSoundID_Vibrate. - 🔢 Plays arbitrary raw IDs that are not part of the enum yet.
- 🗂️ Ships metadata for every sound: the system category it belongs to, so grouped UI comes for free.
- 🤝 Safe cross-platform: all calls are no-ops outside of iOS.
📦 Installation #
Add the latest version with:
flutter pub add ios_system_sound
Then import it:
import 'package:ios_system_sound/ios_system_sound.dart';
Requirements: iOS 13.0+.
🚀 Usage #
🔊 Play a system sound #
final sound = IosSystemSound();
// Camera shutter / 相机快门声
await sound.play(SystemSoundID.photoShutter);
// Message sent
await sound.play(SystemSoundID.sentMessage);
// Unlock
await sound.play(SystemSoundID.unlock);
The returned Future resolves as soon as playback has been handed over to the
system — it does not wait for the sound to finish. System Sound Services
ignores IDs that do not exist on the current device, so nothing else happens in
that case.
⏭️ Play sounds one after another #
Pass waitForCompletion: true and the Future resolves only when the system
reports the playback as finished, so a list of sounds can be played in sequence
without guessing how long each one lasts:
for (final id in SystemSoundID.byCategory[SystemSoundCategory.alert]!) {
await sound.play(id, waitForCompletion: true);
}
vibrate() and playRawId() accept the same flag. On platforms other than iOS
the calls stay no-ops and resolve immediately.
📳 Vibrate #
await sound.vibrate();
🔢 Play a raw sound ID #
Useful for IDs that are missing from the enum, or for sounds created with
AudioServicesCreateSystemSoundID on the native side.
await sound.playRawId(1108); // same as SystemSoundID.photoShutter
🔍 Look up a sound by its value #
SystemSoundID.fromValue(1004); // SystemSoundID.sentMessage
SystemSoundID.tryFromValue(42); // null
SystemSoundID.photoShutter.value; // 1108
SystemSoundID.photoShutter.category; // SystemSoundCategory.camera
🧩 Build grouped UI #
for (final entry in SystemSoundID.byCategory.entries) {
final category = entry.key; // SystemSoundCategory.headset
final sounds = entry.value;
}
🗂️ Sound categories #
| Category | Count | Examples |
|---|---|---|
SystemSoundCategory.mail |
4 | newMail, mailSent, voiceMailReceived |
SystemSoundCategory.sms |
11 | receivedMessage, sentMessage, smsReceived1 |
SystemSoundCategory.alert |
18 | alarm, bloom, noir |
SystemSoundCategory.keyPress |
5 | tink, tock, tinkKeyPressed |
SystemSoundCategory.power |
2 | lowPower, connectedToPower |
SystemSoundCategory.simToolkit |
5 | simToolkitSMS |
SystemSoundCategory.network |
1 | ussd |
SystemSoundCategory.callTone |
6 | ctBusy, ctError, ctCallWaiting |
SystemSoundCategory.device |
5 | lock, unlock, shake |
SystemSoundCategory.camera |
1 | photoShutter |
SystemSoundCategory.recording |
4 | beginRecord, endVideoRecord |
SystemSoundCategory.voiceChat |
9 | jblBegin, vcEnded, vcRinging |
SystemSoundCategory.touchTone |
12 | dtmf0 ... dtmfPound |
SystemSoundCategory.headset |
6 | longLowShortHigh |
SystemSoundCategory.preview |
33 | voicemail2, updateSelection |
SystemSoundCategory.vibration |
3 | vibrate |
SystemSoundCategory.unknown |
1 | webcamStart |
126 sounds in total (SystemSoundID.values.length).
📱 Example app #
The bundled example app browses every sound grouped by category, with a search field that matches sound names, category names and numeric IDs, plus a button for each category that plays every sample in sequence.
cd example && flutter run
Note
The iOS Simulator does not play system sounds — run the example on a real device to hear them.
🌍 Platform behaviour #
System Sound Services only exists on iOS. Calls made from any other platform are
ignored (a message is written with debugPrint in debug builds), so you can
share a single code path across a cross-platform app without extra branching.
| Platform | Behaviour |
|---|---|
| iOS | Plays / vibrates |
| Everything else | No-op |
📝 Notes #
Note
The set of supported sound IDs may vary slightly across iOS versions and devices. This library is being continuously supplemented.
Note
Sounds played via System Sound Services are not subject to Audio Session configuration, so they cannot be aligned with other audio behaviour in your app. This is the main reason to avoid using System Sound Services for anything other than its intended purpose.
🔗 References #
💛 Support #
If ios_system_sound helps you build better apps, please consider
supporting it.
It only takes a few seconds and helps other Flutter developers discover the
library.
☕️ Buy Me a Coffee #
| Buy Me a Coffee | Donate with PayPal |
|---|---|
![]() |
![]() |


