1

Which API should I use to play sound notification from a Mobile browser for my web application.

Any Idea?

I don't want to use Flash or Silverlight Plugin.I used phonegap notification API, but it doesn't work on my iPhone.

You valuable thoughts would be highly appreciated.

Abdullah

Abdullah Saqib
  • 161
  • 1
  • 2
  • 6

2 Answers2

1

Unfortunately the iOS browser has some limitations purposely built into it. One of them being that you can't play audio in javascript unless it comes as a direct response to user interaction (click/tap). The reasoning for this limitation is unclear to me, my guess is that this is a deliberate attempt to cripple web apps and favour native apps.

This limitation is mentioned in Safari official docs here: https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/PlayingandSynthesizingSounds/PlayingandSynthesizingSounds.html#//apple_ref/doc/uid/TP40009523-CH6-SW1

"On iOS, the Web Audio API requires sounds to be triggered from an explicit user action, such as a tap."

asiop
  • 707
  • 4
  • 11
0

You could try playing the sound with javascript

Playing sound notifications using Javascript?

Community
  • 1
  • 1
teebot
  • 1,089
  • 2
  • 12
  • 25