objective c - Ask for Permission for Local Notifications in iOS 8, but still have the App Support iOS 7 -
I have an app that uses local notifications Everything works fine in iOS 7, but in iOS 8 The app needs to ask for permission of the user to display the information I am using to ask for permission in iOS 8:
- (bool) Application: (UIApplication *) Application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions {[application registerUserNotificationSettings: [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories: zero]]; } It works fine in Xcode 6 and iOS 8. When I open the same project in Xcode 5, the error is a semantic issue. Use the undisclosed identifier 'UIUserNotificationSettings'. "
I will call the app for iOS 7 & amp; 8, and notifications work properly on both versions
makes some assumptions in the following answer: / P>
- The application should build properly with a base SDK of iOS 8 when using Xcode 6 and it will build properly with a base SDK of iOS 7 while using Xcode 5.
- The base SDK and Xcode version
code:
< Code> - (bool) Application:. (UIApplication *) application didFinishLaunchingWithOptions: Any of the (NSDictionary *) launchOptions {// code should be compiled even until the base SDK is iOS 8.0 or later __IPHONE_OS_VERSION_MAX_ALLOWED & gt #if; = 80000 // The following line should be run only under iOS 8. This sequence checks // It prevents them from displaying it does not exist (like running under iOS 7 or earlier). If ([application respondsToSelector: @selector (registerUserNotificationSettings :)) {application registerUserNotificationSettings: [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound section: zero]]; } #endif} All this is included in Apple.
Comments
Post a Comment