Platforms to show: All Mac Windows Linux Cross-Platform
UNNotificationSoundMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | User Notifications | MBS MacFrameworks Plugin | 19.1 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Create a UNNotificationSoundMBS object when you want the delivery of your notification to be accompanied by a specific sound. To play the default system sound, create your sound object using the defaultSound method. If you want to play a custom sound, create a new sound object and specify the name of the audio file that you want to play.
For local notifications, assign the sound object to the sound property of your UNMutableNotificationContentMBS object. For a remote notification, assign the name of your sound file to the sound key in the aps dictionary. You can also use a notification service app extension to add a sound file to a notification shortly before delivery. In your extension, create a UNNotificationSound object and add it to your notification content in the same way that you would for a local notification.
Audio files must already be on the user’s device before they can be played. If you use a predefined set of sounds for your notifications, include the audio files in your app’s bundle. For all other sounds, place a copy of the audio file in the Library/Sounds folder of your app’s container directory. The UNNotificationSound object looks only in those two locations.
Prepare Sound Resources
The system sound facility plays custom alert sounds, so they must be in one of the following audio data formats:
- Linear PCM
- MA4 (IMA/ADPCM)
- µLaw
- aLaw
You can use the afconvert command-line tool to convert sounds. For example, to convert the system sound Submarine.aiff to IMA4 audio in a CAF file, use the following command in Terminal:
afconvert /System/Library/Sounds/Submarine.aiff ~/Desktop/sub.caf -d ima4 -f caff -v
This is an abstract class. You can't create an instance, but you can get one from various plugin functions.
- property Handle as Integer
- 2 methods
- method Constructor Private
- method copy as UNNotificationSoundMBS
- 7 shared methods
- shared method Available as boolean
- shared method criticalSoundNamed(name as string) as UNNotificationSoundMBS
- shared method criticalSoundNamed(name as string, volume as double) as UNNotificationSoundMBS
- shared method defaultCriticalSound as UNNotificationSoundMBS
- shared method defaultCriticalSoundWithAudioVolume(volume as double) as UNNotificationSoundMBS
- shared method defaultSound as UNNotificationSoundMBS
- shared method soundNamed(name as string) as UNNotificationSoundMBS
This class has no sub classes.
Some properties using for this class:
- UNMutableNotificationContentMBS.sound as UNNotificationSoundMBS
- UNNotificationContentMBS.sound as UNNotificationSoundMBS
The items on this page are in the following plugins: MBS MacFrameworks Plugin.
UNNotificationSettingsMBS - UNNotificationTriggerMBS