UILocalNotifications播放自定义声音

Muh*_*qib 9 iphone ios uilocalnotification

我在我的应用程序中实现了本地通知,但我只是想知道是否有一种方法可以播放不属于主要iPhone应用程序包的声音.基本上在我的应用程序中,我希望用户录制在生成本地通知时播放的声音,而不是播放预先录制的或默认声音.据我所知,这可以实现,因为我已经在应用程序商店中看到2-3个应用商店正在做同样的事我想做

- (void)alertSelector:(NSString *)AlertTitle WithFiringTime:(NSDate *)date
{ 

UILocalNotification *localNotification = [[[UILocalNotification alloc] init] autorelease];
   [localNotification setFireDate:date];
   [localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
   NSDictionary *data = [NSDictionary dictionaryWithObject:date forKey:@"payload"];       
   [localNotification setUserInfo:data];[localNotification setAlertBody:AlertTitle];   
   [localNotification setAlertAction:@"View"]; [localNotification setHasAction:YES]; 
   localNotification.soundName=@"voice.aif"; 

   if (!localNotification)
          return;

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 
}
Run Code Online (Sandbox Code Playgroud)

Aks*_*hay 0

从该房产的描述来看soundName——

\n\n
\n

对于此属性,请指定应用程序\xe2\x80\x99s 主包中声音资源的文件名(包括扩展名)或\n UILocalNotificationDefaultSoundName以请求默认系统\n 声音。

\n
\n\n

除了捆绑包中存在的声音之外,似乎无法使用其他声音。您确定应用程序正在使用带有自定义声音的本地通知吗?也许他们正在播放带有警报的声音或类似的东西。

\n\n

哈特哈,

\n\n

阿克谢

\n