uilocalnotification - Swift: Local notifications seem to duplicate then some vanish -


i have reminder app searching through array send reminders take medication. when notifications come through, i'm getting sea of multiple notifications coming through , seemingly vanishing instantaneously , 1 remains @ end.

my initial view controller uitableviewcontroller. tried placing firenotifications function in viewdidload didn't seem send notifications. if put firenotifications function call in 1 of tableview functions (ie numberofsectionsintableview) i'm able notifications come through, have odd behavior mentioned above.

my code is:

func firenotifications() {     if nsuserdefaults().boolforkey("notifyswitch") {  //checks settings make sure user wants reminders         (index, items) in mymedslist.enumerate() {             let notification = uilocalnotification()             notification.firedate = nsdate(timeintervalsincenow: 20)             notification.alertbody = "reminder: take \(items.name) now!"             notification.alertaction = "let's take meds!"             notification.soundname = uilocalnotificationdefaultsoundname             notification.userinfo = ["med index": index]             uiapplication.sharedapplication().schedulelocalnotification(notification)         }     } } 

am making mistake in have function call? or there wrong in code? of note, have firedate 20 seconds testing purposes, plan on customizing firedate each item in mymedslist array.

it looks you're adding notifications every time. should add notifications haven't added before. if don't feel doing that, can call cancelalllocalnotifications() before adding them in again.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -