Ios Swift : Add Message Tone and Vibration when notification received -
using ios 9 , swift 2
i have written function call notification when needed.
how add msg tone , vibration when notification received :
func getnotification(message:string) { let curentseting = uiapplication.sharedapplication().currentusernotificationsettings() if(curentseting!.types == .none) { let newseting = uiusernotificationsettings(fortypes: [.alert, .badge, .sound], categories: nil) uiapplication.sharedapplication().registerusernotificationsettings(newseting) } let nfnvar = uilocalnotification() nfnvar.firedate = nsdate(timeintervalsincenow: 0) nfnvar.alertbody = message nfnvar.soundname = uilocalnotificationdefaultsoundname nfnvar.userinfo = ["namkey":"namvey"] uiapplication.sharedapplication().schedulelocalnotification(nfnvar) }
Comments
Post a Comment