cordova-plugin-local-notifications-continued 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +1 -0
- package/.github/ISSUE_TEMPLATE/report_issue.yml +126 -0
- package/CHANGELOG.md +358 -0
- package/LICENSE +202 -0
- package/README.md +1531 -0
- package/images/android-actions-with-input-clicked.png +0 -0
- package/images/android-actions-with-input-not-clicked.png +0 -0
- package/images/android-actions.png +0 -0
- package/images/android-alarms-and-reminders-in-app-settings.png +0 -0
- package/images/android-alarms-and-reminders-setting.png +0 -0
- package/images/android-app-hibernation-notification.png +0 -0
- package/images/android-app-hibernation-settings-android-12.png +0 -0
- package/images/android-app-hibernation-settings-android-13-14.png +0 -0
- package/images/android-app-hibernation-settings-android-15.png +0 -0
- package/images/android-attachments-image-folded.png +0 -0
- package/images/android-attachments-image-unfolded.png +0 -0
- package/images/android-chat.png +0 -0
- package/images/android-icon.svg +19 -0
- package/images/android-inbox.png +0 -0
- package/images/android-notification-example.png +0 -0
- package/images/android-progress.png +0 -0
- package/images/android-request-permission.png +0 -0
- package/images/android-stack.png +0 -0
- package/images/apple-icon.svg +1 -0
- package/images/cordova-app-notified-logo.png +0 -0
- package/images/ios-actions-with-input.png +0 -0
- package/images/ios-actions.png +0 -0
- package/images/ios-attachments-image-folded.png +0 -0
- package/images/ios-attachments-image-unfolded.png +0 -0
- package/images/ios-notification.png +0 -0
- package/images/ios-request-permission.png +0 -0
- package/images/logo.png +0 -0
- package/package.json +53 -0
- package/plugin.xml +266 -0
- package/src/android/ClickActivity.java +72 -0
- package/src/android/LocalNotification.java +779 -0
- package/src/android/Manager.java +327 -0
- package/src/android/Notification.java +844 -0
- package/src/android/Options.java +956 -0
- package/src/android/OptionsTrigger.java +104 -0
- package/src/android/action/Action.java +214 -0
- package/src/android/action/ActionGroup.java +135 -0
- package/src/android/build/localnotification.gradle +29 -0
- package/src/android/receiver/ClearReceiver.java +61 -0
- package/src/android/receiver/RestoreReceiver.java +70 -0
- package/src/android/receiver/TriggerReceiver.java +70 -0
- package/src/android/trigger/TriggerHandler.java +195 -0
- package/src/android/trigger/TriggerHandlerAt.java +63 -0
- package/src/android/trigger/TriggerHandlerEvery.java +257 -0
- package/src/android/trigger/TriggerHandlerIn.java +69 -0
- package/src/android/util/AssetUtil.java +385 -0
- package/src/android/util/CallbackContextUtil.java +88 -0
- package/src/android/util/PluginFileProvider.java +34 -0
- package/src/android/xml/shared_files_provider_paths.xml +38 -0
- package/src/ios/APPLocalNotification.h +56 -0
- package/src/ios/APPLocalNotification.m +650 -0
- package/src/ios/APPNotificationCategory.h +28 -0
- package/src/ios/APPNotificationCategory.m +107 -0
- package/src/ios/APPNotificationContent.h +32 -0
- package/src/ios/APPNotificationContent.m +122 -0
- package/src/ios/APPNotificationOptions.h +42 -0
- package/src/ios/APPNotificationOptions.m +689 -0
- package/src/ios/UNNotificationRequest+APPLocalNotification.h +32 -0
- package/src/ios/UNNotificationRequest+APPLocalNotification.m +100 -0
- package/src/ios/UNUserNotificationCenter+APPLocalNotification.h +60 -0
- package/src/ios/UNUserNotificationCenter+APPLocalNotification.m +344 -0
- package/www/local-notification.js +1104 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Apache 2.0 License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Sebastian Katzer 2017
|
|
5
|
+
*
|
|
6
|
+
* This file contains Original Code and/or Modifications of Original Code
|
|
7
|
+
* as defined in and that are subject to the Apache License
|
|
8
|
+
* Version 2.0 (the 'License'). You may not use this file except in
|
|
9
|
+
* compliance with the License. Please obtain a copy of the License at
|
|
10
|
+
* http://opensource.org/licenses/Apache-2.0/ and read it before using this
|
|
11
|
+
* file.
|
|
12
|
+
*
|
|
13
|
+
* The Original Code and all software distributed under the License are
|
|
14
|
+
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
|
15
|
+
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
|
16
|
+
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
|
18
|
+
* Please see the License for the specific language governing rights and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#import "APPNotificationOptions.h"
|
|
23
|
+
#import "UNNotificationRequest+APPLocalNotification.h"
|
|
24
|
+
#import "APPNotificationContent.h"
|
|
25
|
+
#import <objc/runtime.h>
|
|
26
|
+
|
|
27
|
+
@import UserNotifications;
|
|
28
|
+
|
|
29
|
+
static char optionsKey;
|
|
30
|
+
|
|
31
|
+
@implementation UNNotificationRequest (APPLocalNotification)
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get associated option object
|
|
35
|
+
*/
|
|
36
|
+
- (APPNotificationOptions*) getOptions
|
|
37
|
+
{
|
|
38
|
+
return objc_getAssociatedObject(self, &optionsKey);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Set associated option object
|
|
43
|
+
*/
|
|
44
|
+
- (void) setOptions:(APPNotificationOptions*)options
|
|
45
|
+
{
|
|
46
|
+
objc_setAssociatedObject(self, &optionsKey,
|
|
47
|
+
options, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The options provided by the plug-in.
|
|
52
|
+
*/
|
|
53
|
+
- (APPNotificationOptions*) options
|
|
54
|
+
{
|
|
55
|
+
APPNotificationOptions* options = [self getOptions];
|
|
56
|
+
|
|
57
|
+
if (!options) {
|
|
58
|
+
options = [[APPNotificationOptions alloc]
|
|
59
|
+
initWithDict:[self.content userInfo]];
|
|
60
|
+
|
|
61
|
+
[self setOptions:options];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return options;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* If the notification was updated.
|
|
69
|
+
*
|
|
70
|
+
* @return [ BOOL ]
|
|
71
|
+
*/
|
|
72
|
+
- (BOOL) wasUpdated
|
|
73
|
+
{
|
|
74
|
+
return [self.content userInfo][@"updatedAt"] != NULL;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Encode the user info dict to JSON.
|
|
79
|
+
*/
|
|
80
|
+
- (NSString*) encodeToJSON
|
|
81
|
+
{
|
|
82
|
+
NSString* json;
|
|
83
|
+
NSMutableDictionary* obj = [self.content.userInfo mutableCopy];
|
|
84
|
+
|
|
85
|
+
[obj removeObjectForKey:@"updatedAt"];
|
|
86
|
+
|
|
87
|
+
if (obj == NULL || obj.count == 0) return json;
|
|
88
|
+
|
|
89
|
+
NSData* data = [NSJSONSerialization dataWithJSONObject:obj
|
|
90
|
+
options:NSJSONWritingPrettyPrinted
|
|
91
|
+
error:NULL];
|
|
92
|
+
|
|
93
|
+
json = [[NSString alloc] initWithData:data
|
|
94
|
+
encoding:NSUTF8StringEncoding];
|
|
95
|
+
|
|
96
|
+
return [json stringByReplacingOccurrencesOfString:@"\n"
|
|
97
|
+
withString:@""];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Apache 2.0 License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Sebastian Katzer 2017
|
|
5
|
+
*
|
|
6
|
+
* This file contains Original Code and/or Modifications of Original Code
|
|
7
|
+
* as defined in and that are subject to the Apache License
|
|
8
|
+
* Version 2.0 (the 'License'). You may not use this file except in
|
|
9
|
+
* compliance with the License. Please obtain a copy of the License at
|
|
10
|
+
* http://opensource.org/licenses/Apache-2.0/ and read it before using this
|
|
11
|
+
* file.
|
|
12
|
+
*
|
|
13
|
+
* The Original Code and all software distributed under the License are
|
|
14
|
+
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
|
15
|
+
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
|
16
|
+
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
|
18
|
+
* Please see the License for the specific language governing rights and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#import "APPNotificationContent.h"
|
|
23
|
+
|
|
24
|
+
@interface UNUserNotificationCenter (APPLocalNotification)
|
|
25
|
+
|
|
26
|
+
extern NSString * const kAPPGeneralCategory;
|
|
27
|
+
|
|
28
|
+
typedef NS_ENUM(NSUInteger, APPNotificationType) {
|
|
29
|
+
NotifcationTypeAll = 0,
|
|
30
|
+
NotifcationTypeScheduled = 1,
|
|
31
|
+
NotifcationTypeTriggered = 2,
|
|
32
|
+
NotifcationTypeUnknown = 3
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
#define APPNotificationType_DEFINED
|
|
36
|
+
|
|
37
|
+
@property (readonly, getter=getNotifications) NSArray* localNotifications;
|
|
38
|
+
@property (readonly, getter=getNotificationIds) NSArray* localNotificationIds;
|
|
39
|
+
|
|
40
|
+
- (void) registerGeneralNotificationCategory;
|
|
41
|
+
- (void) addActionGroup:(UNNotificationCategory*)category;
|
|
42
|
+
- (void) removeActionGroup:(NSString*)identifier;
|
|
43
|
+
- (BOOL) hasActionGroup:(NSString*)identifier;
|
|
44
|
+
|
|
45
|
+
- (NSArray*) getNotificationIdsByType:(APPNotificationType)type;
|
|
46
|
+
|
|
47
|
+
- (UNNotificationRequest*) getNotificationWithId:(NSNumber*)id;
|
|
48
|
+
- (APPNotificationType) getTypeOfNotificationWithId:(NSNumber*)id;
|
|
49
|
+
|
|
50
|
+
- (NSArray*) getNotificationOptions;
|
|
51
|
+
- (NSArray*) getNotificationOptionsById:(NSArray*)ids;
|
|
52
|
+
- (NSArray*) getNotificationOptionsByType:(APPNotificationType)type;
|
|
53
|
+
|
|
54
|
+
- (void) clearNotification:(UNNotificationRequest*)notification;
|
|
55
|
+
- (void) clearNotifications;
|
|
56
|
+
|
|
57
|
+
- (void) cancelNotification:(UNNotificationRequest*)notification;
|
|
58
|
+
- (void) cancelNotifications;
|
|
59
|
+
|
|
60
|
+
@end
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Apache 2.0 License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Sebastian Katzer 2017
|
|
5
|
+
*
|
|
6
|
+
* This file contains Original Code and/or Modifications of Original Code
|
|
7
|
+
* as defined in and that are subject to the Apache License
|
|
8
|
+
* Version 2.0 (the 'License'). You may not use this file except in
|
|
9
|
+
* compliance with the License. Please obtain a copy of the License at
|
|
10
|
+
* http://opensource.org/licenses/Apache-2.0/ and read it before using this
|
|
11
|
+
* file.
|
|
12
|
+
*
|
|
13
|
+
* The Original Code and all software distributed under the License are
|
|
14
|
+
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
|
|
15
|
+
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
|
|
16
|
+
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
|
|
18
|
+
* Please see the License for the specific language governing rights and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#import "UNUserNotificationCenter+APPLocalNotification.h"
|
|
23
|
+
#import "UNNotificationRequest+APPLocalNotification.h"
|
|
24
|
+
|
|
25
|
+
@import UserNotifications;
|
|
26
|
+
|
|
27
|
+
NSString * const kAPPGeneralCategory = @"GENERAL";
|
|
28
|
+
|
|
29
|
+
@implementation UNUserNotificationCenter (APPLocalNotification)
|
|
30
|
+
|
|
31
|
+
#pragma mark -
|
|
32
|
+
#pragma mark NotificationCategory
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Register general notification category to listen for dismiss actions.
|
|
36
|
+
*/
|
|
37
|
+
- (void) registerGeneralNotificationCategory
|
|
38
|
+
{
|
|
39
|
+
UNNotificationCategory* category = [UNNotificationCategory categoryWithIdentifier:kAPPGeneralCategory
|
|
40
|
+
actions:@[]
|
|
41
|
+
intentIdentifiers:@[]
|
|
42
|
+
options:UNNotificationCategoryOptionCustomDismissAction];
|
|
43
|
+
|
|
44
|
+
[self setNotificationCategories:[NSSet setWithObject:category]];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Add the specified category to the list of categories.
|
|
49
|
+
* @param addCategory The category to add.
|
|
50
|
+
*/
|
|
51
|
+
- (void) addActionGroup:(UNNotificationCategory*)addCategory
|
|
52
|
+
{
|
|
53
|
+
if (!addCategory) return;
|
|
54
|
+
|
|
55
|
+
[self getNotificationCategoriesWithCompletionHandler:^(NSSet<UNNotificationCategory *> *categories) {
|
|
56
|
+
NSMutableSet* mutableCategories = [NSMutableSet setWithSet:categories];
|
|
57
|
+
|
|
58
|
+
// Remove category first, if it already exists
|
|
59
|
+
for (UNNotificationCategory* category in mutableCategories)
|
|
60
|
+
{
|
|
61
|
+
if ([addCategory.identifier isEqualToString:category.identifier]) {
|
|
62
|
+
[mutableCategories removeObject:category];
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
NSLog(@"Adding action category: %@", addCategory.identifier);
|
|
68
|
+
[mutableCategories addObject:addCategory];
|
|
69
|
+
[self setNotificationCategories:mutableCategories];
|
|
70
|
+
}];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Remove if the specified category does exist.
|
|
75
|
+
* @param removeCategoryIdentifier The category id to remove.
|
|
76
|
+
*/
|
|
77
|
+
- (void) removeActionGroup:(NSString*)removeCategoryIdentifier
|
|
78
|
+
{
|
|
79
|
+
[self getNotificationCategoriesWithCompletionHandler:^(NSSet<UNNotificationCategory *> *categories) {
|
|
80
|
+
NSMutableSet* mutableCategories = [NSMutableSet setWithSet:categories];
|
|
81
|
+
|
|
82
|
+
for (UNNotificationCategory* category in mutableCategories)
|
|
83
|
+
{
|
|
84
|
+
if ([category.identifier isEqualToString:removeCategoryIdentifier]) {
|
|
85
|
+
[mutableCategories removeObject:category];
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
[self setNotificationCategories:mutableCategories];
|
|
91
|
+
}];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Check if the specified category does exist.
|
|
96
|
+
* @param findCategoryIdentifier The category id to check for.
|
|
97
|
+
* @return [ BOOL ]
|
|
98
|
+
*/
|
|
99
|
+
- (BOOL) hasActionGroup:(NSString*)findCategoryIdentifier
|
|
100
|
+
{
|
|
101
|
+
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
102
|
+
__block BOOL found = NO;
|
|
103
|
+
|
|
104
|
+
[self getNotificationCategoriesWithCompletionHandler:^(NSSet<UNNotificationCategory *> *categories) {
|
|
105
|
+
for (UNNotificationCategory* category in categories)
|
|
106
|
+
{
|
|
107
|
+
if ([category.identifier isEqualToString:findCategoryIdentifier]) {
|
|
108
|
+
found = YES;
|
|
109
|
+
dispatch_semaphore_signal(semaphore);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}];
|
|
114
|
+
|
|
115
|
+
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
|
116
|
+
|
|
117
|
+
return found;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
#pragma mark -
|
|
121
|
+
#pragma mark LocalNotifications
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* List of all delivered or still pending notifications.
|
|
125
|
+
* @return [ NSArray<UNNotificationRequest*>* ]
|
|
126
|
+
*/
|
|
127
|
+
- (NSArray*) getNotifications
|
|
128
|
+
{
|
|
129
|
+
NSMutableArray* notifications = [[NSMutableArray alloc] init];
|
|
130
|
+
[notifications addObjectsFromArray:[self getPendingNotifications]];
|
|
131
|
+
[notifications addObjectsFromArray:[self getDeliveredNotifications]];
|
|
132
|
+
return notifications;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* List of all triggered notifications.
|
|
137
|
+
* @return [ NSArray<UNNotificationRequest*>* ]
|
|
138
|
+
*/
|
|
139
|
+
- (NSArray*) getDeliveredNotifications
|
|
140
|
+
{
|
|
141
|
+
NSMutableArray* notifications = [[NSMutableArray alloc] init];
|
|
142
|
+
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
|
|
143
|
+
|
|
144
|
+
[self getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> *delivered) {
|
|
145
|
+
for (UNNotification* notification in delivered)
|
|
146
|
+
{
|
|
147
|
+
[notifications addObject:notification.request];
|
|
148
|
+
}
|
|
149
|
+
dispatch_semaphore_signal(sema);
|
|
150
|
+
}];
|
|
151
|
+
|
|
152
|
+
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
|
|
153
|
+
|
|
154
|
+
return notifications;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* List of all pending notifications.
|
|
159
|
+
* @return [ NSArray<UNNotificationRequest*>* ]
|
|
160
|
+
*/
|
|
161
|
+
- (NSArray*) getPendingNotifications
|
|
162
|
+
{
|
|
163
|
+
NSMutableArray* notificationsRequests = [[NSMutableArray alloc] init];
|
|
164
|
+
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
165
|
+
|
|
166
|
+
[self getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> *requests) {
|
|
167
|
+
[notificationsRequests addObjectsFromArray:requests];
|
|
168
|
+
dispatch_semaphore_signal(semaphore);
|
|
169
|
+
}];
|
|
170
|
+
|
|
171
|
+
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
|
172
|
+
|
|
173
|
+
return notificationsRequests;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* List of all notifications from given type.
|
|
178
|
+
* @param type Notification life cycle type.
|
|
179
|
+
* @return [ NSArray<UNNotificationRequest>* ]
|
|
180
|
+
*/
|
|
181
|
+
- (NSArray*) getNotificationsByType:(APPNotificationType)type
|
|
182
|
+
{
|
|
183
|
+
switch (type) {
|
|
184
|
+
case NotifcationTypeScheduled:
|
|
185
|
+
return [self getPendingNotifications];
|
|
186
|
+
|
|
187
|
+
case NotifcationTypeTriggered:
|
|
188
|
+
return [self getDeliveredNotifications];
|
|
189
|
+
|
|
190
|
+
default:
|
|
191
|
+
return [self getNotifications];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* List of all local notifications IDs.
|
|
197
|
+
* @return [ NSArray<int>* ]
|
|
198
|
+
*/
|
|
199
|
+
- (NSArray*) getNotificationIds
|
|
200
|
+
{
|
|
201
|
+
NSMutableArray* ids = [[NSMutableArray alloc] init];
|
|
202
|
+
|
|
203
|
+
for (UNNotificationRequest* notification in [self getNotifications])
|
|
204
|
+
{
|
|
205
|
+
[ids addObject:notification.options.id];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return ids;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* List of all notifications IDs from given type.
|
|
213
|
+
* @param type Notification life cycle type.
|
|
214
|
+
* @return [ NSArray<int>* ]
|
|
215
|
+
*/
|
|
216
|
+
- (NSArray*) getNotificationIdsByType:(APPNotificationType)type
|
|
217
|
+
{
|
|
218
|
+
NSMutableArray* ids = [[NSMutableArray alloc] init];
|
|
219
|
+
|
|
220
|
+
for (UNNotificationRequest* notification in [self getNotificationsByType:type])
|
|
221
|
+
{
|
|
222
|
+
[ids addObject:notification.options.id];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return ids;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Find notification by ID.
|
|
230
|
+
* @param findNotificationId Notification ID
|
|
231
|
+
* @return [ UNNotificationRequest* ]
|
|
232
|
+
*/
|
|
233
|
+
- (UNNotificationRequest*) getNotificationWithId:(NSNumber*)findNotificationId
|
|
234
|
+
{
|
|
235
|
+
for (UNNotificationRequest* notification in [self getNotifications])
|
|
236
|
+
{
|
|
237
|
+
NSString* notificationId = [NSString stringWithFormat:@"%@", notification.options.id];
|
|
238
|
+
|
|
239
|
+
if ([notificationId isEqualToString:[findNotificationId stringValue]]) {
|
|
240
|
+
return notification;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return NULL;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Find notification type by ID.
|
|
249
|
+
* @param notificationId The ID of the notification.
|
|
250
|
+
* @return [ APPNotificationType ]
|
|
251
|
+
*/
|
|
252
|
+
- (APPNotificationType) getTypeOfNotificationWithId:(NSNumber*)notificationId
|
|
253
|
+
{
|
|
254
|
+
// Check if triggered
|
|
255
|
+
if ([[self getNotificationIdsByType:NotifcationTypeTriggered] containsObject:notificationId]) return NotifcationTypeTriggered;
|
|
256
|
+
|
|
257
|
+
// Check if scheduled
|
|
258
|
+
if ([[self getNotificationIdsByType:NotifcationTypeScheduled] containsObject:notificationId]) return NotifcationTypeScheduled;
|
|
259
|
+
|
|
260
|
+
return NotifcationTypeUnknown;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* List of properties from all notifications.
|
|
265
|
+
* @return [ NSArray<APPNotificationOptions*>* ]
|
|
266
|
+
*/
|
|
267
|
+
- (NSArray*) getNotificationOptions
|
|
268
|
+
{
|
|
269
|
+
return [self getNotificationOptionsByType:NotifcationTypeAll];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* List of properties from all notifications of given type.
|
|
274
|
+
* @param type Notification life cycle type.
|
|
275
|
+
* @return [ NSArray<APPNotificationOptions*>* ]
|
|
276
|
+
*/
|
|
277
|
+
- (NSArray*) getNotificationOptionsByType:(APPNotificationType)type
|
|
278
|
+
{
|
|
279
|
+
NSMutableArray* options = [[NSMutableArray alloc] init];
|
|
280
|
+
|
|
281
|
+
for (UNNotificationRequest* notification in [self getNotificationsByType:type])
|
|
282
|
+
{
|
|
283
|
+
[options addObject:notification.options.userInfo];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return options;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* List of properties from given local notifications.
|
|
291
|
+
* @param notificationsIds The ids of the notifications to find.
|
|
292
|
+
* @return [ NSArray<APPNotificationOptions*>* ]
|
|
293
|
+
*/
|
|
294
|
+
- (NSArray*) getNotificationOptionsById:(NSArray*)notificationsIds
|
|
295
|
+
{
|
|
296
|
+
NSMutableArray* options = [[NSMutableArray alloc] init];
|
|
297
|
+
|
|
298
|
+
for (UNNotificationRequest* notification in [self getNotifications])
|
|
299
|
+
{
|
|
300
|
+
if ([notificationsIds containsObject:notification.options.id]) {
|
|
301
|
+
[options addObject:notification.options.userInfo];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return options;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Clear all notfications.
|
|
310
|
+
*/
|
|
311
|
+
- (void) clearNotifications
|
|
312
|
+
{
|
|
313
|
+
[self removeAllDeliveredNotifications];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Clear Specified notfication.
|
|
318
|
+
*/
|
|
319
|
+
- (void) clearNotification:(UNNotificationRequest*)notificationRequest
|
|
320
|
+
{
|
|
321
|
+
[self removeDeliveredNotificationsWithIdentifiers:@[notificationRequest.identifier]];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Cancel all notfications.
|
|
326
|
+
*/
|
|
327
|
+
- (void) cancelNotifications
|
|
328
|
+
{
|
|
329
|
+
[self removeAllPendingNotificationRequests];
|
|
330
|
+
[self removeAllDeliveredNotifications];
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Cancel specified notfication.
|
|
335
|
+
* @param notificationRequest The notification object.
|
|
336
|
+
*/
|
|
337
|
+
- (void) cancelNotification:(UNNotificationRequest*)notificationRequest
|
|
338
|
+
{
|
|
339
|
+
NSArray* ids = @[notificationRequest.identifier];
|
|
340
|
+
[self removeDeliveredNotificationsWithIdentifiers:ids];
|
|
341
|
+
[self removePendingNotificationRequestsWithIdentifiers:ids];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
@end
|