How can I access default iOS sound to set it as no

2019-03-15 15:07发布

How can I access default iOS sound (Tri-tone, Chime, Glass, Horn, Bell, Electronic...) to set it as local notification sound?

I've created local notification, everything works but with default sound (which is Tri-tone). I want to use Chime or another

I only know how to use my own sound files:

localNotif.soundName = @"sound.wav";

3条回答
forever°为你锁心
2楼-- · 2019-03-15 15:37

Audio services are not private. The methods are documented in the developers reference guide and referenced in the Multimedia Programming guide.

All you need to do if figure out the reference id of the sound you want to play.

查看更多
萌系小妹纸
3楼-- · 2019-03-15 15:43

check out this site.

If you want to play a Default System Sound. refer a following code, but private Frameworks. you will be rejected.

AudioServicesPlaySystemSound(1004);

and check out other this sample code (No private frameworks. supported a Apple).

查看更多
够拽才男人
4楼-- · 2019-03-15 15:48

System sounds are not available you your app, unfortunately. From the docs:

Note: System-supplied alert sounds and system-supplied user-interface sound effects are not available to your iOS application. For example, using the kSystemSoundID_UserPreferredAlert constant as a parameter to the AudioServicesPlayAlertSound function will not play anything.

Update

While Apple does say you can't access system sounds, I suppose they must mean that you can't access them for your own purposes, but I see that UILocalNotification.h provides:

UIKIT_EXTERN NSString *const UILocalNotificationDefaultSoundName; 

"Identifies the default system sound to play when a notification alert is displayed. You assign this value to the soundName property." I am now using this in my app and it seems to work fine.

查看更多
登录 后发表回答