uilocalnotification - Changes to registerUserNotificationSettings in Swift 2? -
i can't seem find documentation on registerusernotificationsettings beyond produced last november (here), old code doesn't seem work me more in xcode 7 , swift 2.
i have code in app delegate:
let endgameaction = uimutableusernotificationaction() endgameaction.identifier = "end_game" endgameaction.title = "end game" endgameaction.activationmode = .background endgameaction.authenticationrequired = false endgameaction.destructive = true let continuegameaction = uimutableusernotificationaction() continuegameaction.identifier = "continue_game" continuegameaction.title = "continue" continuegameaction.activationmode = .foreground continuegameaction.authenticationrequired = false continuegameaction.destructive = false let restartgamecategory = uimutableusernotificationcategory() restartgamecategory.identifier = "restart_category" restartgamecategory.setactions([continuegameaction, endgameaction], forcontext: .default) restartgamecategory.setactions([endgameaction, continuegameaction], forcontext: .minimal) application.registerusernotificationsettings(uiusernotificationsettings(fortypes: [.alert, .badge, .sound], categories: (nsset(array: [restartgamecategory])) set<nsobject>)) i receive following 2 errors on final line of code:
'element.protocol' not have member named 'alert'
and
cannot invoke 'registerusernotificationsettings' argument list of type '(uiusernotificationsettings)'
i've searched information on changes, can't find anything. missing obvious?
instead of using (nsset(array: [restartgamecategory])) set<nsobject>) (nsset(array: [restartgamecategory])) as? set<uiusernotificationcategory>) so:
application.registerusernotificationsettings( uiusernotificationsettings( fortypes: [.alert, .badge, .sound], categories: (nsset(array: [restartgamecategory])) as? set<uiusernotificationcategory>))
Comments
Post a Comment