ios - How to show multiple local notifications -


background:

im writing application bot sends messages. these messages can received local notification.

the problem:

when bot sends multiple notifications within short span of time (1 second between each message), notification center show 1 message. hear notification sound every time expect to, still see first message.

relevant code:

func postusernotification(content: string, delay: timeinterval, withdictionary dictionary: [string:string] = [:]) {      let notificationcontent = unmutablenotificationcontent()     notificationcontent.body = content     notificationcontent.userinfo = dictionary     notificationcontent.categoryidentifier = "message"      let dateafterdelay = date(timeintervalsincenow: delay)      let datecomponents = calendar.current.datecomponents([.year,.month,.day,.hour,.minute,.second], from: dateafterdelay)       let trigger = uncalendarnotificationtrigger(datematching: datecomponents, repeats: false)      let identifier = "identifier" + "\(notificationmanager.incrementor)"      let localnotification = unnotificationrequest(identifier: identifier, content: notificationcontent, trigger: trigger)      unusernotificationcenter.current().add(localnotification){ (error : error?) in         if let theerror = error {             print("the error \(theerror.localizeddescription)")         }     } } 

nothing wrong code :

like wrote in question, mentioned in apple docs:

if sending multiple notifications same device or  computer within short period of time, push service send  last one. 

https://developer.apple.com/library/content/technotes/tn2265/_index.html#//apple_ref/doc/uid/dts40010376-ch1-tntag23


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -