Change the sound file of the push notification, it only works after iOS reboot

I have a problem with an iOS application to access a file in the Library/Sounds directory.

My iOS application delivers various sound files to the main application package. I wrote code that copies the selected file to the Library/Sounds directory. It always has the same name ( foo.caf ) in this directory.

That way, I can switch to different push notification sounds. If I do this for the first time, everything will be fine. But if I switch to another application and I get a push notification, there is no more sound. Also, the default sound is not played. But it’s strange that if I restart the iPhone and receive a new push notification, I get a newly selected sound.

Does iOS have some cache or something else that I should reset first? Or is it an iOS bug?

EDIT:

I wrote a small demo project to reproduce the problem. It can be found at:

Source code: https://github.com/patricks/PushNotificationSoundSwitch/releases

Git Repo: https://github.com/patricks/PushNotificationSoundSwitch

Readme file: https://github.com/patricks/PushNotificationSoundSwitch/blob/master/README.md

+5
source share

Source: https://habr.com/ru/post/1241436/


All Articles