IOS push notification type options? Warning against banner?

Here I read the messages that the only way to make PUSH notifications as a warning instead of a banner is for an individual end user to change the Alert Style in the Notifications section of the Settings application. What puzzles me is that there are applications that by default use the Alerts style without doing this.

Is there a way to programmatically set the Alerts style through a dialog on first run? I do not mind asking the user to confirm in the dialog box. I just know, since other applications do not require the user to manually enter the settings in order to change the notification style, there must be another way to do this ...

I have the following -

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)]; return YES; } 
+6
source share
2 answers

Your application has the right to check the notification settings, you can never set or change the types of notifications for the user.

When requesting notification types, the following options

 typedef NS_OPTIONS(NSUInteger, UIRemoteNotificationType) { UIRemoteNotificationTypeNone = 0, UIRemoteNotificationTypeBadge = 1 << 0, UIRemoteNotificationTypeSound = 1 << 1, UIRemoteNotificationTypeAlert = 1 << 2, UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3, } 

All you can learn from the push settings request is that the user did not turn on notifications, but not how they are displayed (banner versus warning).

+7
source

No, this is not possible; you cannot do this.

You can use this line to query the current notification style settings:

 UIRemoteNotificationType* enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; 

You can check the activated types, and then instruct the user to change the notification style in the settings.

+2
source

Source: https://habr.com/ru/post/955261/


All Articles