0

I am developing an chat app in which user can send and receive messages.I done it through push notification.I store all messages in table,So i display all send and receive mesages when user selects a contact.By default push notification making sound when app is closed.How do i add beep sound when app is open.

user2003416
  • 159
  • 2
  • 9

1 Answers1

2

Use the didReceiveRemoteNotification delegate for this:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    if ( application.applicationState == UIApplicationStateActive )
    {
      //create an audio player and play the sound
    }
}
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
  • How do i add default push notification sound with audio player?. – user2003416 Feb 08 '13 at 13:46
  • @user2003416: You need to add a sound like that to bundle and play it or you can use this example (System default) – Midhun MP Feb 08 '13 at 13:55
  • @user2003416: http://stackoverflow.com/questions/7856896/couldnt-play-system-sound-after-switching-to-ios-5, http://stackoverflow.com/questions/7831671/playing-system-sound-without-importing-your-own,https://gist.github.com/zoul/205857 – Midhun MP Feb 08 '13 at 14:09
  • I do not know basics of audio player.basic example will be helpful – user2003416 Feb 08 '13 at 14:35