ios - How to make a local notification alert with sound -


i want set sound in local notification when app in foregroundmode. m try lot of thing . please me.

      uint32 flag = 0;    systemsoundid soundid;         int err = audioservicessetproperty(kaudioservicespropertyisuisound,                                        sizeof(uint32),                                        &uilocalnotificationdefaultsoundname,                                        sizeof(uint32),                                        &flag);          nslog(@"%d",(unsigned int)err);          audioservicesplaysystemsound(soundid); 

if trying launch local notification sound can use soundname property:

uilocalnotification *localnotif = [[uilocalnotification alloc] init]; localnotif.firedate = [nsdate datewithtimeintervalsincenow:30]; localnotif.alertbody = @"hey!"; localnotif.alerttitle = @"notification!";  localnotif.soundname = uilocalnotificationdefaultsoundname; [[uiapplication sharedapplication] schedulelocalnotification:localnotif]; 

with uilocalnotificationdefaultsoundname notification use default sound, use filename instead custom sound.

more on property in documentation.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -