Timering

Purp

Convert audio files for UNNotification custom sounds

First you need to prepare your sound, which must be maximum 30 seconds long. If you use a sound file is longer than 30 seconds, the system plays the default sound instead.

Part of the Series:

IOS10 - UserNotification.framework - UNNotification tutorial Obj-C 

IOS10 - UserNotification Framework in Swift

The type and data format

You allowed to use  aiff , wav, or caf files. And it must be one of the following data format: 

  • Linear PCM
  • MA4 (IMA/ADPCM)
  • µLaw
  • aLaw

For sound effects, the best choose is .caf, for music aiff.

So, maybe you have just an wav file.  And you really don't know, which data format. You can check it in your Terminal with this code:

and drag and drop your file after the code and press enter. It looks like this:

afinfo tutorial

You can see all infos here. That will be useful to check the result before using the new audio file. 

With the first example, you can convert your wav file to caf with Linear PCM data format with this code: 

You have to drag and drop your file to terminal after your code, and do that again, and rewrite the end of the file from wav to caf. 

Press enter, and you can see your .caf file in Finder. Finally you can check the data format again with $ afinfo. 

You can find here the all options for afconvert:

NEXT

The next part of the series: The same tutorial in Swift

Share & Follow

If you would like to be notified of my new solutions, please subscribe to my Newsletter or my youtube channel and/ or follow me on Facebook or Twitter! Check Footer section for these opportunities!