List of local iOS notifications after the notification was issued
My app is running in the background and watching for bluetooth data. When data comes in, I show a notification that the user needs to open the app so that I can process the data just coming in.
I am writing in iOS 5 and later.
I am making my notice using this code:
UILocalNotification* alarm = [[[UILocalNotification alloc] init] autorelease];
if (alarm) {
alarm.fireDate = [NSDate date];
alarm.timeZone = [NSTimeZone defaultTimeZone];
alarm.repeatInterval = 0;
alarm.soundName = @"alarmsound.caf";
alarm.alertBody = message;
[app scheduleLocalNotification:alarm];
}
As I hope you can see from this code, the notification is triggered immediately.
The problem I am running into is that I cannot detect that there is already a notification in the notification bar. I've tried using:
NSArray *oldNotifications = [app scheduledLocalNotifications];
// Clear out the old notification before scheduling a new one.
if ([oldNotifications count] > 0)
[app cancelAllLocalNotifications];
This doesn't seem to work because the oldNotifications score is always 0, although there is a ton in the notification bar. I'm guessing this is because notifications are already running?
Basically I only want to notify the user once unless they dismiss that notification without opening the app. It would be nice if I could increase the value of the app icon so that the user knows how many Bluetooth messages have appeared. Instead, I just get a new notification for each incoming message.
How can I just notify the user once and then only notify if they have dismissed the notification?
source to share
No one has answered this question yet
Check out similar questions: