|
|
@@ -71,19 +71,56 @@
|
|
|
#pragma mark -
|
|
|
#pragma mark LocalNotifications
|
|
|
|
|
|
+/**
|
|
|
+ * List of all local notifications which have been added
|
|
|
+ * but not yet removed from the notification center.
|
|
|
+ */
|
|
|
+- (NSArray*) localNotifications
|
|
|
+{
|
|
|
+ NSArray* scheduledNotifications = self.scheduledLocalNotifications;
|
|
|
+ NSMutableArray* notifications = [[NSMutableArray alloc] init];
|
|
|
+
|
|
|
+ for (UILocalNotification* notification in scheduledNotifications)
|
|
|
+ {
|
|
|
+ if (notification) {
|
|
|
+ [notifications addObject:notification];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return notifications;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * List of all local notifications which have been scheduled
|
|
|
+ * and not yet removed from the notification center.
|
|
|
+ */
|
|
|
+- (NSArray*) scheduledLocalNotifications2
|
|
|
+{
|
|
|
+ NSArray* scheduledNotifications = self.scheduledLocalNotifications;
|
|
|
+ NSMutableArray* notifications = [[NSMutableArray alloc] init];
|
|
|
+
|
|
|
+ for (UILocalNotification* notification in scheduledNotifications)
|
|
|
+ {
|
|
|
+ if (notification && [notification wasScheduled]) {
|
|
|
+ [notifications addObject:notification];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return notifications;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* List of all triggered local notifications which have been scheduled
|
|
|
* and not yet removed the notification center.
|
|
|
*/
|
|
|
- (NSArray*) triggeredLocalNotifications
|
|
|
{
|
|
|
- NSArray* scheduledNotifications = self.scheduledLocalNotifications;
|
|
|
+ NSArray* notifications = self.localNotifications;
|
|
|
NSMutableArray* triggeredNotifications = [[NSMutableArray alloc] init];
|
|
|
|
|
|
- for (UILocalNotification* notification in scheduledNotifications)
|
|
|
+ for (UILocalNotification* notification in notifications)
|
|
|
{
|
|
|
- if (notification && [notification wasTriggered])
|
|
|
- {
|
|
|
+ if ([notification wasTriggered]) {
|
|
|
[triggeredNotifications addObject:notification];
|
|
|
}
|
|
|
}
|
|
|
@@ -93,7 +130,24 @@
|
|
|
|
|
|
/**
|
|
|
* List of all triggered local notifications IDs which have been scheduled
|
|
|
- * and not yet removed the notification center.
|
|
|
+ * and not yet removed from the notification center.
|
|
|
+ */
|
|
|
+- (NSArray*) localNotificationIds
|
|
|
+{
|
|
|
+ NSArray* notifications = self.localNotifications;
|
|
|
+ NSMutableArray* ids = [[NSMutableArray alloc] init];
|
|
|
+
|
|
|
+ for (UILocalNotification* notification in notifications)
|
|
|
+ {
|
|
|
+ [ids addObject:notification.options.id];
|
|
|
+ }
|
|
|
+
|
|
|
+ return ids;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * List of all added local notifications IDs which have been scheduled
|
|
|
+ * and not yet removed from the notification center.
|
|
|
*/
|
|
|
- (NSArray*) triggeredLocalNotificationIds
|
|
|
{
|
|
|
@@ -113,32 +167,50 @@
|
|
|
*/
|
|
|
- (NSArray*) scheduledLocalNotificationIds
|
|
|
{
|
|
|
- NSArray* notifications = self.scheduledLocalNotifications;
|
|
|
+ NSArray* notifications = self.scheduledLocalNotifications2;
|
|
|
NSMutableArray* ids = [[NSMutableArray alloc] init];
|
|
|
|
|
|
for (UILocalNotification* notification in notifications)
|
|
|
{
|
|
|
- if (notification) {
|
|
|
- [ids addObject:notification.options.id];
|
|
|
- }
|
|
|
+ [ids addObject:notification.options.id];
|
|
|
}
|
|
|
|
|
|
return ids;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Get the scheduled local notification by ID.
|
|
|
+ * Get local notification by ID.
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * Notification ID
|
|
|
+ */
|
|
|
+- (UILocalNotification*) localNotificationWithId:(NSString*)id
|
|
|
+{
|
|
|
+ NSArray* notifications = self.localNotifications;
|
|
|
+
|
|
|
+ for (UILocalNotification* notification in notifications)
|
|
|
+ {
|
|
|
+ if ([notification.options.id isEqualToString:id]) {
|
|
|
+ return notification;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Get scheduled local notification by ID.
|
|
|
*
|
|
|
* @param id
|
|
|
* Notification ID
|
|
|
*/
|
|
|
- (UILocalNotification*) scheduledLocalNotificationWithId:(NSString*)id
|
|
|
{
|
|
|
- NSArray* notifications = self.scheduledLocalNotifications;
|
|
|
+ NSArray* notifications = self.scheduledLocalNotifications2;
|
|
|
|
|
|
for (UILocalNotification* notification in notifications)
|
|
|
{
|
|
|
- if (notification && [notification.options.id isEqualToString:id]) {
|
|
|
+ if ([notification.options.id isEqualToString:id]) {
|
|
|
return notification;
|
|
|
}
|
|
|
}
|
|
|
@@ -147,14 +219,14 @@
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Get the triggered local notification by ID.
|
|
|
+ * Get triggered local notification by ID.
|
|
|
*
|
|
|
* @param id
|
|
|
* Notification ID
|
|
|
*/
|
|
|
- (UILocalNotification*) triggeredLocalNotificationWithId:(NSString*)id
|
|
|
{
|
|
|
- UILocalNotification* notification = [self scheduledLocalNotificationWithId:id];
|
|
|
+ UILocalNotification* notification = [self localNotificationWithId:id];
|
|
|
|
|
|
if (notification && [notification wasTriggered]) {
|
|
|
return notification;
|
|
|
@@ -163,38 +235,68 @@
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * List of properties from all notifications.
|
|
|
+ */
|
|
|
+- (NSArray*) localNotificationOptions
|
|
|
+{
|
|
|
+ NSArray* notifications = self.localNotifications;
|
|
|
+ NSMutableArray* options = [[NSMutableArray alloc] init];
|
|
|
+
|
|
|
+ for (UILocalNotification* notification in notifications)
|
|
|
+ {
|
|
|
+ [options addObject:notification.userInfo];
|
|
|
+ }
|
|
|
+
|
|
|
+ return options;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* List of properties from all scheduled notifications.
|
|
|
*/
|
|
|
- (NSArray*) scheduledLocalNotificationOptions
|
|
|
{
|
|
|
- NSArray* notifications = self.scheduledLocalNotifications;
|
|
|
+ NSArray* notifications = [self scheduledLocalNotifications2];
|
|
|
NSMutableArray* options = [[NSMutableArray alloc] init];
|
|
|
|
|
|
for (UILocalNotification* notification in notifications)
|
|
|
{
|
|
|
- if (notification) {
|
|
|
- [options addObject:notification.userInfo];
|
|
|
- }
|
|
|
+ [options addObject:notification.userInfo];
|
|
|
}
|
|
|
|
|
|
return options;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * List of properties from given scheduled notifications.
|
|
|
+ * List of properties from all triggered notifications.
|
|
|
+ */
|
|
|
+- (NSArray*) triggeredLocalNotificationOptions
|
|
|
+{
|
|
|
+ NSArray* notifications = self.triggeredLocalNotifications;
|
|
|
+ NSMutableArray* options = [[NSMutableArray alloc] init];
|
|
|
+
|
|
|
+ for (UILocalNotification* notification in notifications)
|
|
|
+ {
|
|
|
+ [options addObject:notification.userInfo];
|
|
|
+ }
|
|
|
+
|
|
|
+ return options;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * List of properties from given local notifications.
|
|
|
*
|
|
|
* @param ids
|
|
|
* Notification IDs
|
|
|
*/
|
|
|
-- (NSArray*) scheduledLocalNotificationOptions:(NSArray*)ids
|
|
|
+- (NSArray*) localNotificationOptions:(NSArray*)ids
|
|
|
{
|
|
|
UILocalNotification* notification;
|
|
|
NSMutableArray* options = [[NSMutableArray alloc] init];
|
|
|
|
|
|
for (NSString* id in ids)
|
|
|
{
|
|
|
- notification = [self scheduledLocalNotificationWithId:id];
|
|
|
+ notification = [self localNotificationWithId:id];
|
|
|
|
|
|
if (notification) {
|
|
|
[options addObject:notification.userInfo];
|
|
|
@@ -205,16 +307,23 @@
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * List of properties from all triggered notifications.
|
|
|
+ * List of properties from given scheduled notifications.
|
|
|
+ *
|
|
|
+ * @param ids
|
|
|
+ * Notification IDs
|
|
|
*/
|
|
|
-- (NSArray*) triggeredLocalNotificationOptions
|
|
|
+- (NSArray*) scheduledLocalNotificationOptions:(NSArray*)ids
|
|
|
{
|
|
|
- NSArray* notifications = self.triggeredLocalNotifications;
|
|
|
+ UILocalNotification* notification;
|
|
|
NSMutableArray* options = [[NSMutableArray alloc] init];
|
|
|
|
|
|
- for (UILocalNotification* notification in notifications)
|
|
|
+ for (NSString* id in ids)
|
|
|
{
|
|
|
- [options addObject:notification.userInfo];
|
|
|
+ notification = [self scheduledLocalNotificationWithId:id];
|
|
|
+
|
|
|
+ if (notification) {
|
|
|
+ [options addObject:notification.userInfo];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return options;
|