0

so I have an app which fires a local notification after a certain amount of time. The only problem is that I require the alert style which pops up once the notification goes off to be an actual alert not a banner. From what I've researched I've found that you can request from the user, the ability to change the format of the notification (very much like requesting the use of notifications). I am however, unsure of how to implement this in code. Does anyone have any ideas as to how I can achieve this? Any help on the topic is very much appreciated.

imjonu
  • 515
  • 1
  • 6
  • 12
  • You'll need an alert for requesting authorization after the user changed their mind or first time when app is launched? – Mannopson Feb 04 '17 at 06:46
  • yes that's what I'm after but I am unsure of how to actually do that in code. – imjonu Feb 04 '17 at 08:42
  • If the user changed their mind and stop using notifications for your app? You can get the authorization status by using getNotificationSettings method of UNUserNotificationCenter and that returns immediately. You'll get fast status results. – Mannopson Feb 04 '17 at 10:47

1 Answers1

0

Notification alerts, both local and remote, are handled by OS when the app is not in foreground and you have no control on them, on how appears. Only user can choose in Settings how they appears. When the app is in foreground, instead, you can choose how to show them (or ignore at all, for example)

EDIT

After your comment, I suppose you want to know which notification alert style user chosen. In this case you should use:

UNUserNotificationCenter.current().getNotificationSettings(){ (settings) in

    switch settings.alertStyle{
        case .alert:                
            print("user prefers alert")                
        case .banner:                
            print("user prefers banner")                
        case .none:
            print("user disabled alerts")
    }
}
carmine
  • 1,597
  • 2
  • 24
  • 33