我在我的应用程序中使用了UILocalNotification
。当我的应用位于前台时,它不会播放任何声音,但是当我的应用进入后台时,它工作正常(它会播放声音(。为什么?
这就是通知的工作方式。 从文档中:
如果应用程序在前台运行,则没有警报, 徽章或声音;相反, 如果
application:didReceiveLocalNotification:
委托实现它。
如果要在应用运行时响应通知,则需要在应用委托中自行执行此操作:
- (void) application:(UIApplication *)application didReceiveLocalNotification: (UILocalNotification *)notification
{
// Play your sound, display a message, etc.
}