Hi Reader’s,
This blog includes the concept of how to use custom sound for notifications when application is in foreground/active mode. Below is the code in objective C language for the same which you have to write in AppDelegate file :-
SystemSoundID soundID; // Make this variable global
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef ref = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"pager.aif", NULL, NULL);
AudioServicesCreateSystemSoundID(ref, &soundID);
AudioServicesPlaySystemSound(soundID);
pager.aif is the file name which includes the custom sound which will play when you use the above mentioned code. After sound play we need to stop the sound on some particular action or on some conditions. Below is the code to stop the sound according to the need :-
AudioServicesRemoveSystemSoundCompletion (soundID);
AudioServicesDisposeSystemSoundID(soundID);
I hope this blog will help you to understand the concept of how to use custom sound for notifications when application is in foreground/active mode.
0 Comment(s)