iosaudiopush-notificationmute

Cancel a push notification sound while it is playing


Tried to find this already but can't find any questions which are asking quite the same thing.

Basically I have set up my push notifications, everything works fine and they are received both when the app is open and closed. However, the push noise we are using is quite long and I'm not sure if it's possible to cancel the sound once they press the "ok" button on the alert.

I have tried to utilise the mute toggle switch, but this only seems to come into play at the moment that sound starts to play, if it's off the sound plays, if it's on then it doesn't. If I toggle the switch mid-sound it has no effect. However, if I just play a regular sound clip in my app (not a push notification sound) and use the toggle switch then the sound stops/starts as you would expect.

Is there a way to cancel the sound? Or is it treated differently as a system sound of some kind?

Edit: I've been trying to work this out myself for the last few days, and I'm coming to the conclusion that there is no way to cancel the push alert sound mid-sound. Can anyone confirm that this is definitely the case?

Edit2: For some reason the xcode tag has been removed - with the reason being that it is nothing to do with xcode. I feel maybe my issue was not clear - I AM using xcode to build the app, and I am looking for a way to programatically control whether the push notification sound is heard or not. Thanks.


Solution

  • No answers given, having tried and failed over the last few months I can only assume this is not possible (just in case anyone has the same issue in the future).