UILocalNotification play sound from app documents

谁说我不能喝 提交于 2019-12-04 08:19:52

A surefire way to get an NSURL to the application documents directory is like this...

NSURL *documentsDirectoryURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];

Then you can get an NSURL reference to your sound file like this...

NSURL *soundURL = [documentsDirectoryURL URLByAppendingPathComponent:@"sound.caf"];

If you need a string representation of the path to the resource at that URL you can obtain it like this...

NSString *pathRepresentation = [soundURL absoluteString];

I checked next method work on ios 5.0.1:

just setup relative path like this

notify.soundName = @"../Documents/blabla.caf"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!