嗨,我正在使用警报应用程序,并使用警报音乐(例如铃声)设置LocalNotifications。我完美地播放了铃声。但是问题是单击AlertView中的“确定”按钮后,正在播放铃声。如何立即播放以接收LocalNotification

我正在使用以下代码播放铃声:

-(void)application:(UIApplication *)application
didReceiveLocalNotification:(UILocalNotification *)notification

{

      application.applicationIconBadgeNumber = 0;

      NSString *reminderText = [notification.userInfo objectForKey:kRemindMeNotificationDataKey];

      NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Mitwa.mp3", [[NSBundle mainBundle] resourcePath]]];

      NSError *error;
      player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
      player.numberOfLoops = -1;

      if (player == nil)
        NSLog([error description]);
      else
        [player play];

      [viewController showReminder:@"Good Evening Mahesh!"];

  }

请在收到通知后帮助我发出警报。

谢谢...

最佳答案

使用UILocalNotification我们可以设置警报,并且可以为该UILocalNotification设置声音,但是该声音应该只有30秒。对于本地通知,您不能播放超过30秒的声音。如果您想在点击警报后播放歌曲,我们可以在您的应用中播放歌曲。

关于iphone - 如何在iPhone应用程序中播放闹钟音乐?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13819423/

10-10 20:38
查看更多