38

Starting with iOS 5, there are two notification styles: banner and alert (the "old" style). A user can set which style to use for each application in the settings. However, the default now seems to be that notifications are displayed banner style.

I'm using local notifications for reminders about events that will happen "now". A banner disappears shortly after it appeared (and it's not obvious enough that one can tap it), so for these notifications it would be desirable to have the alert style notifications as those stay on screen until the user decided on an action (ignore or go to app).

Is there a way either through code or for example Info.plist entries to tell iOS that the alert style notifications should be used by default (as long as the user hasn't configured something else)?

Update: The absence of information/documentation is not enough for me to have this settled. I want either something like a forum/blog post from someone with authority (Apple employee or someone along the lines of Erica Sadun) saying it's not possible, or if it is possible then I want the solution. A workaround like "ask the user to change the setting" isn't good enough either.

DarkDust
  • 90,870
  • 19
  • 190
  • 224
  • have you tried using the method on page 53-54 of this doc? http://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/iphoneappprogrammingguide.pdf – DanZimm Nov 24 '11 at 15:49
  • @DanZimm: The problem is not scheduling local notifications. The problem is to tell iOS to use the alert style to display them by default. The documentation you've cited doesn't tell anything about that. – DarkDust Nov 24 '11 at 16:25
  • gotcha - i thought maybe the way a uilocalnotification is created and configured might affect its appearance, my bad :P – DanZimm Nov 24 '11 at 16:39
  • have you got the correct answer to this? we are also trying to find a solution to this. – IBG Feb 03 '12 at 09:30
  • @IBG: Since [someone else filed a radar for this](http://openradar.appspot.com/9570818) I didn't bother. So no, I don't have an answer to this yet. – DarkDust Feb 03 '12 at 10:51
  • Any news now that we are in 2014 with iOS7? I can't believe how they don't let you set a default style in a plist, which the user can later change from the settings. So frustrating! – Jan Apr 02 '14 at 21:34

6 Answers6

20

I would like to add something, since I've opened a TSI and somehow I asked about this and have been answered. From Quinn "The Eskimo!":

"This depends on you mean. You have some control over how the notification appears based on how you set the UILocalNotification properties (things like alertBody, soundName, and so on). However, if you're asking about the way in which those properties are interpreted (the things the user can customise in Settings > Notifications), those are user preferences and not exposed via any API."

IBG
  • 465
  • 12
  • 34
  • Its The real answer to the question, for further help , here is what I observed – MMujtabaRoohani Jun 04 '15 at 14:07
  • 1
    alert style depends upon the 3 properties i.e alertBody, alertAction and alertTitle, if you only provide alert body then style would be banner, if none of these is provided then it would be none else it would be alert – MMujtabaRoohani Jun 04 '15 at 14:11
  • @JProgrammer I've provided all three, but it's still banner. What am I doing wrong? – abjurato Jan 04 '16 at 08:15
16

I have an alarm app for which I also need this functionality. Under iOS5 if the user is using another app when it goes off then the banner appears. Consequently I spent a lot of time browsing for a solution.

However, it's not possible to control the style of alert generated by a UILocalNotification I'm afraid :(

You can see from the class reference that there's no provision for it:

http://developer.apple.com/library/IOs/#documentation/iPhone/Reference/UILocalNotification_Class/Reference/Reference.html

Or in the plist:

http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html

Best thing to do is tell the user what to do to change the settings.

tarmes
  • 15,366
  • 10
  • 53
  • 87
  • I'm afraid the absence of any properties in `UILocalNotification` is not good enough to settle this. For example, there could be a `Info.plist` key that would specify a default. – DarkDust Nov 24 '11 at 16:23
  • 3
    No offense, but I don't consider you authoritative even though you seem to put some effort into this. But I doubt you've looked at the iOS binaries or dug any deeper than reading documentation. Still, I appreciate the effort which is why I've given you a +1. – DarkDust Nov 29 '11 at 07:35
11

You probably won't find 'authoritative' from your peers here, you should better ask directly to Apple; and the question has already been asked several times on theirs forums and not answered...

The HIG programming guide - http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/TechnologyUsage/TechnologyUsage.html#//apple_ref/doc/uid/TP40006556-CH18-SW1 -

"iOS apps that support local or push notifications can participate in Notification Center in various ways, depending on the user’s preferences."

That last sentence is the only 'authoritative hint' i found.

The USER'S preferences <= you can't force the user ('s preferences). Period. This design choice is clearly the Apple Way (applications' playground IS limited, to ensure the best user experience possible)

As for more authority... maybe shouting ?

NO YOU CAN'T CHOOSE YOUR NOTIFICATIONS DISPLAY STYLE, IT'S THE USER'S CHOICE

Just kidding... Anyway, a workaround might be to provide a way in your application - hint/ tutorial - to push the user to change the alert style himself...

good luck !

Vinzzz
  • 11,746
  • 5
  • 36
  • 42
  • I already plan to file a radar once the bounty period is over, when I asked the question I was hoping that I don't have to but it quickly became obvious that this will be the only way to have this answered once and for all ;-) – DarkDust Nov 29 '11 at 13:59
4

Obviously you don't like hearing no for an answer, but, no.

David Dunham
  • 8,139
  • 3
  • 28
  • 41
  • 1
    I have no problem with the answer "No", but it must be an authoritative "No". So, if you can back that up, for example with a link to some documentation or posting from someone who really has saying in the matter (like an Apple employee or, say, a high profile hacker like someone from iPhone Dev Team), then you'll get the bounty :-) – DarkDust Nov 28 '11 at 19:02
  • Well, I've spend a long time looking and I've not found a solution. Given the time involved I'd say my response is now authoritative, so it would be nice if at least two people would vote on it so that I can can half the bounty :) You'll find it among the other responses.... – tarmes Nov 28 '11 at 19:21
  • This is essentially the same question I see asked about once a day: how can my app behave entirely differently from all the others? How can I completely change the iOS UI? This sort of thing isn't ever going to be possible. It doesn't scale. (Maybe your alarm app really does need to be different. But then every fart app would be doing it too.) – David Dunham Nov 28 '11 at 22:02
  • 2
    @David Dunham: No, it's not about being different. iOS has two different notification styles and for our use case the alert style makes more sense so we would want to have that as default. And the reason why I want an _authoritative_ answer is _exactly_ so that others can have this solved as well. – DarkDust Nov 29 '11 at 07:30
0

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

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

You can check the enabledTypes and then instruct the user to change the notification style in the settings.

voyager
  • 85
  • 5
  • 1
    Unfortunately this can only determine that alert is enabled or not but cannot find out the style of the alert. See definition: typedef NS_OPTIONS(NSUInteger, UIRemoteNotificationType) { UIRemoteNotificationTypeNone = 0, UIRemoteNotificationTypeBadge = 1 << 0, UIRemoteNotificationTypeSound = 1 << 1, UIRemoteNotificationTypeAlert = 1 << 2, UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3, } NS_ENUM_AVAILABLE_IOS(3_0); – fabe Feb 28 '14 at 18:30
-2

have you tried

[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];

in your didFinishLaunching method, this won't help those updating but should enable alerts for those first installing

zambono
  • 1,397
  • 1
  • 17
  • 26
  • You're talking about *remote* notifications (and miss the `UIRemoteNotificationTypeAlert`), but I'm talking about *local* notifications. The documentation doesn't talk about influencing local notifications so I very much doubt it'll have an effect. – DarkDust Dec 01 '11 at 07:47
  • based on what people have commented this call should also be used to enable the app in notification center even if it only uses local notifications. – zambono Dec 01 '11 at 12:27
  • This does not change anything - even when setting UIRemoteNotificationTypeAlert at install time still Badge style appears by default – user387184 Aug 05 '12 at 20:02
  • Yeah its about "local notifications" here, but still registerForRemoteNotificationTypes will simply ask the user for permission, it does not set the style of notification none, banner or alert. See: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/IPhoneOSClientImp.html#//apple_ref/doc/uid/TP40008194-CH103-SW1 – serge-k May 26 '15 at 19:20