Swift 3.0 Syntax change for UIUserNotificationSettings

后端 未结 3 1076
滥情空心
滥情空心 2021-02-13 11:53

I am using swift 3.0 and am trying to add badge numbers to my app. I believe the correct way to do this is similar to what is below.

application.registerUserNoti         


        
3条回答
  •  后悔当初
    2021-02-13 12:14

    "rawValue" can use | operator.

    This code works in swift3, we don't need to do that though.

    let types = UIUserNotificationType(rawValue:UIUserNotificationType.alert.rawValue | UIUserNotificationType.sound.rawValue | UIUserNotificationType.badge.rawValue)
    
    application.registerUserNotificationSettings(UIUserNotificationSettings(types: types, categories: nil))
    

提交回复
热议问题