What exactly I wanted is to change the Notification Alert Style to "Alerts" But came to know that we can't do it programatically.
Now lets come to the Scenario,
I have a UILocalNotification
set with the repeatinterval = kCFCalendarUnitMinute
. So each minute it shows new notification in the notification Window if I don't cancel it.
Now Say, I have kept the device idle for 10 minutes then I will be bombarded with 10 notifications though I have set a single notification with repeatinterval.
MAIN QUESTION: Is there any way that only the last notification is displayed.
Like I have given the Example of 1 minute in the same way Take an example of Repeating each 7 days. Cancelling the Notification will cancel the upcoming notification of the next week too.
The only thing Common in all these 10 notifications is the fireDate
with nextFireDate
value as different each time.
Because of this I wanted to switch the alert Style to "Alerts" but since we cannot change it through code.
I need to alert user at each startup to change his Notification alert Style" to "Alerts" Which by default is Banner until he change it.
So now I have 2 questions with dependencies:
- Is there any way to CHECK the current Notification Alert Style i.e
None, Banner, Alerts
for the current app through Coding? - If for 1 its YES, then, Is there any way to take the user directly to the Set notification Alert Style Screen right away from our app.
Note: For Point 2.
One thing in my mind is to show user the path to reach there "Settings-> Notifications -> MyAlarmApp -> Alert Style -> Alerts".
Any other suggestions are most welcome.
You can't change or detect the style of notification programmatically, only the user change this in the settings app.
You also can't open the settings app anymore, thus it will be up to the user who the notification will be displayed. It's totally out of your control.
Like you stated you could ask the user to change the way notification are displayed for your app.
1.The application can check which notification types are enabled using this:
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
2.You can not directly open Setting app screen programmatically now.
You can use this in iOS versions 5.0 - 5.0.1.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];
But it was then depreciated in iOS 5.1. You can not use it for iOS 5.1 and later.
来源:https://stackoverflow.com/questions/13046135/how-to-check-notification-alert-style-for-our-app