简体   繁体   中英

How to mute “UIRemoteNotificationType was deprecated” with the iOS sdk 8.3 in Swift

In my Application I need to keep support for iOS 7. Since some of the Api available for iOS 8 are not available in iOS 7 I switch my code depending on the user's system.

    if operatingSystem() > 7 {
        let types = UIUserNotificationType.Alert | UIUserNotificationType.Sound
        let settings = UIUserNotificationSettings(forTypes: types, categories: nil)
        UIApplication.sharedApplication().registerUserNotificationSettings(settings)
        UIApplication.sharedApplication().registerForRemoteNotifications()
    }else {
        UIApplication.sharedApplication().registerForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound)
    }

Obviously the block of code for iOS 7 contains deprecated code but I need to keep it in my Application. Is it possible to mute the warning?

Please note that this question refers to swift and not objective-c. I cannot use #pragma to add clang information.

You have to enter -Wno- to negate a warning. eg: -Wno-unused-parameter in the compiler flags column from the build phases tab of your project. Go to project then target then the tab then the compile sources phase. There are the compiler flags.

Should work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM