Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use custom sound for notifications when application is in foreground/active mode?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 528
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: