UNAlertStyle determines whether a notification is presented as a banner or an alert. The current authorization settings for the app can be viewed with getNotificationSettingsWithCompletionHandler. If UNAuthorizationOptionAlert was requested (and allowed) the default style seems to be UNAlertStyleBanner, but I can find no way to specify that a local notification be presented as an alert other than the user going into the notificatinon settings.
The settings resulting from asking for UNAuthorizationOptionAlert don't make sense to me. The following test app asks for authorization for alerts and sounds, then NSLog's the resulting notification settings:
#import "AppDelegate.h"
#import <UserNotifications/UserNotifications.h>
@interface AppDelegate () {
UNUserNotificationCenter* center;
}
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
center = [UNUserNotificationCenter currentNotificationCenter];
// request authorization for sounds and alerts
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound)
completionHandler:^(BOOL granted, NSError * _Nullable error) {
NSLog(@"requestAuthorizationWithOptions granted: %i", granted);
// check resulting notification settings
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
NSLog(@"getNotificationSettings: %@", settings);
}];
}];
return YES;
}
The resulting settings show alerts NotSupported (but CarPlay which was not requested is Enabled!):
authorizationStatus: Authorized,
notificationCenterSetting: Enabled,
soundSetting: Enabled,
badgeSetting: NotSupported,
lockScreenSetting: Enabled,
alertSetting: NotSupported,
carPlaySetting: Enabled,
alertStyle: Banner
Any suggestions?
but I can find no way to specify that a local notification be presented as an alert other than the user going into the notificatinon settings
You can't find it because it doesn't exist. The banner is default notification alert format and your app can't change that. UNAlertStyle Is not settable by the app; it reports the user's setting, that's all.