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.
Comments
Post a Comment