Set default iOS local notification style for application

27,052

Solution 1

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."

Solution 2

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.

Solution 3

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 !

Solution 4

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

Share:
27,052
DarkDust
Author by

DarkDust

Used to be a Linux expert (e.g. built an in-house embedded Linux distribution using cross-compiling with which several appliances in the VoIP field were produced). Now a Mac/iPhone/iPad developer.

Updated on March 31, 2020

Comments

  • DarkDust
    DarkDust about 4 years

    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
    DarkDust over 12 years
    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
    DarkDust over 12 years
    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 :-)
  • tarmes
    tarmes over 12 years
    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....
  • David Dunham
    David Dunham over 12 years
    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.)
  • DarkDust
    DarkDust over 12 years
    @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
    DarkDust over 12 years
    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
    DarkDust over 12 years
    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
    DarkDust over 12 years
    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.
  • zambono
    zambono over 12 years
    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.
  • user387184
    user387184 almost 12 years
    This does not change anything - even when setting UIRemoteNotificationTypeAlert at install time still Badge style appears by default
  • fabe
    fabe over 10 years
    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);
  • serge-k
    serge-k about 9 years
    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: developer.apple.com/library/ios/documentation/…
  • MMujtabaRoohani
    MMujtabaRoohani about 9 years
    Its The real answer to the question, for further help , here is what I observed
  • MMujtabaRoohani
    MMujtabaRoohani about 9 years
    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
  • abjurato
    abjurato over 8 years
    @JProgrammer I've provided all three, but it's still banner. What am I doing wrong?