UserNotifications user-created using sound as a tone

Use custom sounds as notification sounds

In iOS 10 after,iOS uses a new UserNotifications As the notification API,This allows developers to use images、video、Sound and other rich media content as the notification,While further,You can also use the Notification Content Extension Size customize the content and layout of notice。
If you are self-defined tone notification,Then you can give UNNotificationContent of sound Add property UNNotificationSound Example:

As can be seen from the highlighted lines,Since the specific location defined ring tone is assigned automatically by the system iOS。All to known,These custom tone must be pre-positioned in the app main bundle in,Length should not exceed 30s,Otherwise it will be replaced by a system beep。

Then ,Is there any way,App to makeUsersIt sounds as a notification tone it?

Use user-defined sound as a notification sounds

User-customizable sound,Here we refer users from other app Importingthe sound of、From the siteDownloadthe sound of,Or is our app downloaded from the server's own post-beep。Then,There is no way,Do not put in the app in the preset tone,ButLate loadedIt?

This is rarely mentioned on the web,Actually it is a。If you go read the official document,Then you willThis pageI found this sentence:

Files for custom sounds must be located in your executable’s main bundle or in the Library/Sounds directory of your app’s container directory.

That is,In addition to the preset in the app main bundle In addition to,We can also download voice placed Library/Sounds This directory!

Thus,Download the user to import or sound can be used as a tone! --of course,Do not forget to also follow the provisions of the 30s。

The same time,Due to restrictions api,Preferably, do not repeat,Otherwise, say bad system with which sound as the tone。


UILocalNotification: Playing a Custom Audio File saved in Documents Directory

Original article written by Gerber drop-off:R0uter's Blog » UserNotifications user-created using sound as a tone

Reproduced Please keep the source and description link:

About the Author


The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。


Leave a Reply

Your email address will not be published. Required fields are marked *