@ammarahmed/notifee-react-native 7.3.0

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.
Files changed (215) hide show
  1. package/.gitattributes +3 -0
  2. package/LICENSE +44 -0
  3. package/README.md +131 -0
  4. package/RNNotifee.podspec +39 -0
  5. package/RNNotifeeCore.podspec +33 -0
  6. package/android/build.gradle +116 -0
  7. package/android/gradle.properties +1 -0
  8. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar +0 -0
  9. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.md5 +1 -0
  10. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha1 +1 -0
  11. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha256 +1 -0
  12. package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha512 +1 -0
  13. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom +9 -0
  14. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.md5 +1 -0
  15. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha1 +1 -0
  16. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha256 +1 -0
  17. package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha512 +1 -0
  18. package/android/libs/app/notifee/core/maven-metadata.xml +13 -0
  19. package/android/libs/app/notifee/core/maven-metadata.xml.md5 +1 -0
  20. package/android/libs/app/notifee/core/maven-metadata.xml.sha1 +1 -0
  21. package/android/libs/app/notifee/core/maven-metadata.xml.sha256 +1 -0
  22. package/android/libs/app/notifee/core/maven-metadata.xml.sha512 +1 -0
  23. package/android/lint.xml +5 -0
  24. package/android/proguard-rules.pro +74 -0
  25. package/android/settings.gradle +1 -0
  26. package/android/src/main/AndroidManifest.xml +12 -0
  27. package/android/src/main/java/io/invertase/notifee/NotifeeApiModule.java +349 -0
  28. package/android/src/main/java/io/invertase/notifee/NotifeeEventSubscriber.java +118 -0
  29. package/android/src/main/java/io/invertase/notifee/NotifeeInitProvider.java +55 -0
  30. package/android/src/main/java/io/invertase/notifee/NotifeePackage.java +30 -0
  31. package/android/src/main/java/io/invertase/notifee/NotifeeReactUtils.java +244 -0
  32. package/app.plugin.js +1 -0
  33. package/dist/NotifeeApiModule.d.ts +53 -0
  34. package/dist/NotifeeApiModule.js +607 -0
  35. package/dist/NotifeeApiModule.js.map +1 -0
  36. package/dist/NotifeeJSEventEmitter.d.ts +3 -0
  37. package/dist/NotifeeJSEventEmitter.js +14 -0
  38. package/dist/NotifeeJSEventEmitter.js.map +1 -0
  39. package/dist/NotifeeNativeError.d.ts +15 -0
  40. package/dist/NotifeeNativeError.js +61 -0
  41. package/dist/NotifeeNativeError.js.map +1 -0
  42. package/dist/NotifeeNativeModule.d.ts +14 -0
  43. package/dist/NotifeeNativeModule.js +43 -0
  44. package/dist/NotifeeNativeModule.js.map +1 -0
  45. package/dist/NotifeeNativeModule.web.d.ts +12 -0
  46. package/dist/NotifeeNativeModule.web.js +19 -0
  47. package/dist/NotifeeNativeModule.web.js.map +1 -0
  48. package/dist/index.d.ts +8 -0
  49. package/dist/index.js +43 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/types/Library.d.ts +21 -0
  52. package/dist/types/Library.js +6 -0
  53. package/dist/types/Library.js.map +1 -0
  54. package/dist/types/Module.d.ts +572 -0
  55. package/dist/types/Module.js +6 -0
  56. package/dist/types/Module.js.map +1 -0
  57. package/dist/types/Notification.d.ts +450 -0
  58. package/dist/types/Notification.js +105 -0
  59. package/dist/types/Notification.js.map +1 -0
  60. package/dist/types/NotificationAndroid.d.ts +1276 -0
  61. package/dist/types/NotificationAndroid.js +380 -0
  62. package/dist/types/NotificationAndroid.js.map +1 -0
  63. package/dist/types/NotificationIOS.d.ts +537 -0
  64. package/dist/types/NotificationIOS.js +92 -0
  65. package/dist/types/NotificationIOS.js.map +1 -0
  66. package/dist/types/NotificationWeb.d.ts +5 -0
  67. package/dist/types/NotificationWeb.js +3 -0
  68. package/dist/types/NotificationWeb.js.map +1 -0
  69. package/dist/types/PowerManagerInfo.d.ts +36 -0
  70. package/dist/types/PowerManagerInfo.js +6 -0
  71. package/dist/types/PowerManagerInfo.js.map +1 -0
  72. package/dist/types/Trigger.d.ts +108 -0
  73. package/dist/types/Trigger.js +39 -0
  74. package/dist/types/Trigger.js.map +1 -0
  75. package/dist/utils/id.d.ts +1 -0
  76. package/dist/utils/id.js +16 -0
  77. package/dist/utils/id.js.map +1 -0
  78. package/dist/utils/index.d.ts +16 -0
  79. package/dist/utils/index.js +52 -0
  80. package/dist/utils/index.js.map +1 -0
  81. package/dist/utils/validate.d.ts +15 -0
  82. package/dist/utils/validate.js +93 -0
  83. package/dist/utils/validate.js.map +1 -0
  84. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.d.ts +2 -0
  85. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js +39 -0
  86. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js.map +1 -0
  87. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.d.ts +2 -0
  88. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js +27 -0
  89. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js.map +1 -0
  90. package/dist/validators/validate.d.ts +25 -0
  91. package/dist/validators/validate.js +75 -0
  92. package/dist/validators/validate.js.map +1 -0
  93. package/dist/validators/validateAndroidAction.d.ts +2 -0
  94. package/dist/validators/validateAndroidAction.js +52 -0
  95. package/dist/validators/validateAndroidAction.js.map +1 -0
  96. package/dist/validators/validateAndroidChannel.d.ts +2 -0
  97. package/dist/validators/validateAndroidChannel.js +155 -0
  98. package/dist/validators/validateAndroidChannel.js.map +1 -0
  99. package/dist/validators/validateAndroidChannelGroup.d.ts +2 -0
  100. package/dist/validators/validateAndroidChannelGroup.js +42 -0
  101. package/dist/validators/validateAndroidChannelGroup.js.map +1 -0
  102. package/dist/validators/validateAndroidFullScreenAction.d.ts +2 -0
  103. package/dist/validators/validateAndroidFullScreenAction.js +50 -0
  104. package/dist/validators/validateAndroidFullScreenAction.js.map +1 -0
  105. package/dist/validators/validateAndroidInput.d.ts +2 -0
  106. package/dist/validators/validateAndroidInput.js +54 -0
  107. package/dist/validators/validateAndroidInput.js.map +1 -0
  108. package/dist/validators/validateAndroidNotification.d.ts +2 -0
  109. package/dist/validators/validateAndroidNotification.js +529 -0
  110. package/dist/validators/validateAndroidNotification.js.map +1 -0
  111. package/dist/validators/validateAndroidPressAction.d.ts +2 -0
  112. package/dist/validators/validateAndroidPressAction.js +50 -0
  113. package/dist/validators/validateAndroidPressAction.js.map +1 -0
  114. package/dist/validators/validateAndroidStyle.d.ts +22 -0
  115. package/dist/validators/validateAndroidStyle.js +231 -0
  116. package/dist/validators/validateAndroidStyle.js.map +1 -0
  117. package/dist/validators/validateIOSAttachment.d.ts +6 -0
  118. package/dist/validators/validateIOSAttachment.js +102 -0
  119. package/dist/validators/validateIOSAttachment.js.map +1 -0
  120. package/dist/validators/validateIOSCategory.d.ts +2 -0
  121. package/dist/validators/validateIOSCategory.js +124 -0
  122. package/dist/validators/validateIOSCategory.js.map +1 -0
  123. package/dist/validators/validateIOSCategoryAction.d.ts +2 -0
  124. package/dist/validators/validateIOSCategoryAction.js +59 -0
  125. package/dist/validators/validateIOSCategoryAction.js.map +1 -0
  126. package/dist/validators/validateIOSInput.d.ts +2 -0
  127. package/dist/validators/validateIOSInput.js +32 -0
  128. package/dist/validators/validateIOSInput.js.map +1 -0
  129. package/dist/validators/validateIOSNotification.d.ts +2 -0
  130. package/dist/validators/validateIOSNotification.js +211 -0
  131. package/dist/validators/validateIOSNotification.js.map +1 -0
  132. package/dist/validators/validateIOSPermissions.d.ts +2 -0
  133. package/dist/validators/validateIOSPermissions.js +62 -0
  134. package/dist/validators/validateIOSPermissions.js.map +1 -0
  135. package/dist/validators/validateNotification.d.ts +11 -0
  136. package/dist/validators/validateNotification.js +129 -0
  137. package/dist/validators/validateNotification.js.map +1 -0
  138. package/dist/validators/validateTrigger.d.ts +2 -0
  139. package/dist/validators/validateTrigger.js +104 -0
  140. package/dist/validators/validateTrigger.js.map +1 -0
  141. package/dist/version.d.ts +1 -0
  142. package/dist/version.js.map +1 -0
  143. package/ios/NotifeeCore/Info.plist +22 -0
  144. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.h +28 -0
  145. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m +72 -0
  146. package/ios/NotifeeCore/NotifeeCore+NSURLSession.h +25 -0
  147. package/ios/NotifeeCore/NotifeeCore+NSURLSession.m +55 -0
  148. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.h +37 -0
  149. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +242 -0
  150. package/ios/NotifeeCore/NotifeeCore.h +118 -0
  151. package/ios/NotifeeCore/NotifeeCore.m +784 -0
  152. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.h +34 -0
  153. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.m +70 -0
  154. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.h +39 -0
  155. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.m +68 -0
  156. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.h +38 -0
  157. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.m +224 -0
  158. package/ios/NotifeeCore/NotifeeCoreUtil.h +82 -0
  159. package/ios/NotifeeCore/NotifeeCoreUtil.m +793 -0
  160. package/ios/RNNotifee/NotifeeApiModule.h +25 -0
  161. package/ios/RNNotifee/NotifeeApiModule.m +371 -0
  162. package/ios/RNNotifee/NotifeeExtensionHelper.h +37 -0
  163. package/ios/RNNotifee/NotifeeExtensionHelper.m +37 -0
  164. package/ios/RNNotifee.xcodeproj/project.pbxproj +318 -0
  165. package/jest-mock.js +158 -0
  166. package/package.json +59 -0
  167. package/plugin/build/index.d.ts +3 -0
  168. package/plugin/build/index.js +12 -0
  169. package/plugin/build/index.js.map +1 -0
  170. package/plugin/build/withNotifeeProjectGradlePlugin.d.ts +5 -0
  171. package/plugin/build/withNotifeeProjectGradlePlugin.js +24 -0
  172. package/plugin/build/withNotifeeProjectGradlePlugin.js.map +1 -0
  173. package/plugin/src/index.ts +9 -0
  174. package/plugin/src/withNotifeeProjectGradlePlugin.ts +27 -0
  175. package/plugin/tsconfig.json +9 -0
  176. package/react-native.config.js +11 -0
  177. package/refresh-example.sh +71 -0
  178. package/src/NotifeeApiModule.ts +825 -0
  179. package/src/NotifeeJSEventEmitter.ts +11 -0
  180. package/src/NotifeeNativeError.ts +70 -0
  181. package/src/NotifeeNativeModule.ts +55 -0
  182. package/src/NotifeeNativeModule.web.ts +25 -0
  183. package/src/index.ts +33 -0
  184. package/src/types/Library.ts +28 -0
  185. package/src/types/Module.ts +625 -0
  186. package/src/types/Notification.ts +505 -0
  187. package/src/types/NotificationAndroid.ts +1443 -0
  188. package/src/types/NotificationIOS.ts +681 -0
  189. package/src/types/NotificationWeb.ts +5 -0
  190. package/src/types/PowerManagerInfo.ts +43 -0
  191. package/src/types/Trigger.ts +118 -0
  192. package/src/utils/id.ts +13 -0
  193. package/src/utils/index.ts +47 -0
  194. package/src/utils/validate.ts +92 -0
  195. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfo.ts +45 -0
  196. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.ts +33 -0
  197. package/src/validators/validate.ts +85 -0
  198. package/src/validators/validateAndroidAction.ts +54 -0
  199. package/src/validators/validateAndroidChannel.ts +188 -0
  200. package/src/validators/validateAndroidChannelGroup.ts +49 -0
  201. package/src/validators/validateAndroidFullScreenAction.ts +65 -0
  202. package/src/validators/validateAndroidInput.ts +67 -0
  203. package/src/validators/validateAndroidNotification.ts +704 -0
  204. package/src/validators/validateAndroidPressAction.ts +65 -0
  205. package/src/validators/validateAndroidStyle.ts +315 -0
  206. package/src/validators/validateIOSAttachment.ts +136 -0
  207. package/src/validators/validateIOSCategory.ts +150 -0
  208. package/src/validators/validateIOSCategoryAction.ts +65 -0
  209. package/src/validators/validateIOSInput.ts +38 -0
  210. package/src/validators/validateIOSNotification.ts +296 -0
  211. package/src/validators/validateIOSPermissions.ts +78 -0
  212. package/src/validators/validateNotification.ts +156 -0
  213. package/src/validators/validateTrigger.ts +134 -0
  214. package/src/version.ts +2 -0
  215. package/tsconfig.json +23 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #import <Foundation/Foundation.h>
19
+ #import <React/RCTBridgeModule.h>
20
+ #import <React/RCTEventEmitter.h>
21
+ #import "NotifeeCore.h"
22
+
23
+ @interface NotifeeApiModule : RCTEventEmitter <RCTBridgeModule, NotifeeCoreDelegate>
24
+
25
+ @end
@@ -0,0 +1,371 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #import "NotifeeApiModule.h"
19
+ #import <React/RCTUtils.h>
20
+ #import <UIKit/UIKit.h>
21
+
22
+ static NSString *kReactNativeNotifeeNotificationEvent = @"app.notifee.notification-event";
23
+ static NSString *kReactNativeNotifeeNotificationBackgroundEvent =
24
+ @"app.notifee.notification-event-background";
25
+
26
+ static NSInteger kReactNativeNotifeeNotificationTypeDisplayed = 1;
27
+ static NSInteger kReactNativeNotifeeNotificationTypeTrigger = 2;
28
+ static NSInteger kReactNativeNotifeeNotificationTypeAll = 0;
29
+
30
+ @implementation NotifeeApiModule {
31
+ bool hasListeners;
32
+ NSMutableArray *pendingCoreEvents;
33
+ }
34
+
35
+ #pragma mark - Module Setup
36
+
37
+ RCT_EXPORT_MODULE();
38
+
39
+ - (dispatch_queue_t)methodQueue {
40
+ return dispatch_get_main_queue();
41
+ }
42
+
43
+ - (id)init {
44
+ if (self = [super init]) {
45
+ pendingCoreEvents = [[NSMutableArray alloc] init];
46
+ [NotifeeCore setCoreDelegate:self];
47
+ }
48
+ return self;
49
+ }
50
+
51
+ - (NSArray<NSString *> *)supportedEvents {
52
+ return @[ kReactNativeNotifeeNotificationEvent, kReactNativeNotifeeNotificationBackgroundEvent ];
53
+ }
54
+
55
+ - (void)startObserving {
56
+ hasListeners = YES;
57
+ for (NSDictionary *eventBody in pendingCoreEvents) {
58
+ [self sendNotifeeCoreEvent:eventBody];
59
+ }
60
+ [pendingCoreEvents removeAllObjects];
61
+ }
62
+
63
+ - (void)stopObserving {
64
+ hasListeners = NO;
65
+ }
66
+
67
+ + (BOOL)requiresMainQueueSetup {
68
+ return YES;
69
+ }
70
+
71
+ #pragma mark - Events
72
+
73
+ - (void)didReceiveNotifeeCoreEvent:(NSDictionary *_Nonnull)event {
74
+ if (hasListeners) {
75
+ [self sendNotifeeCoreEvent:event];
76
+ } else {
77
+ [pendingCoreEvents addObject:event];
78
+ }
79
+ }
80
+
81
+ - (void)sendNotifeeCoreEvent:(NSDictionary *_Nonnull)eventBody {
82
+ dispatch_after(
83
+ dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
84
+ if (RCTRunningInAppExtension() ||
85
+ [UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
86
+ [self sendEventWithName:kReactNativeNotifeeNotificationBackgroundEvent body:eventBody];
87
+ } else {
88
+ [self sendEventWithName:kReactNativeNotifeeNotificationEvent body:eventBody];
89
+ }
90
+ });
91
+ }
92
+
93
+ // TODO(helenaford): look into a custom format style for React Native Method signatures
94
+ // clang-format off
95
+
96
+ # pragma mark - React Native Methods
97
+
98
+ RCT_EXPORT_METHOD(cancelNotification:
99
+ (NSString *) notificationId
100
+ resolve:
101
+ (RCTPromiseResolveBlock) resolve
102
+ reject:
103
+ (RCTPromiseRejectBlock) reject
104
+ ) {
105
+ [NotifeeCore cancelNotification:notificationId withNotificationType:kReactNativeNotifeeNotificationTypeAll withBlock:^(NSError *_Nullable error) {
106
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
107
+ }];
108
+ }
109
+
110
+ RCT_EXPORT_METHOD(cancelDisplayedNotification:
111
+ (NSString *) notificationId
112
+ resolve:
113
+ (RCTPromiseResolveBlock) resolve
114
+ reject:
115
+ (RCTPromiseRejectBlock) reject
116
+ ) {
117
+ [NotifeeCore cancelNotification:notificationId withNotificationType:kReactNativeNotifeeNotificationTypeDisplayed withBlock:^(NSError *_Nullable error) {
118
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
119
+ }];
120
+ }
121
+
122
+ RCT_EXPORT_METHOD(cancelTriggerNotification:
123
+ (NSString *) notificationId
124
+ resolve:
125
+ (RCTPromiseResolveBlock) resolve
126
+ reject:
127
+ (RCTPromiseRejectBlock) reject
128
+ ) {
129
+ [NotifeeCore cancelNotification:notificationId withNotificationType:kReactNativeNotifeeNotificationTypeTrigger withBlock:^(NSError *_Nullable error) {
130
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
131
+ }];
132
+ }
133
+
134
+ RCT_EXPORT_METHOD(cancelAllNotifications:
135
+ (RCTPromiseResolveBlock)resolve
136
+ reject:
137
+ (RCTPromiseRejectBlock)reject
138
+ ) {
139
+ [NotifeeCore cancelAllNotifications:kReactNativeNotifeeNotificationTypeAll withBlock:^(NSError *_Nullable error) {
140
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
141
+ }];
142
+ }
143
+
144
+ RCT_EXPORT_METHOD(cancelDisplayedNotifications:
145
+ (RCTPromiseResolveBlock)resolve
146
+ reject:
147
+ (RCTPromiseRejectBlock)reject
148
+ ) {
149
+ [NotifeeCore cancelAllNotifications:kReactNativeNotifeeNotificationTypeDisplayed withBlock:^(NSError *_Nullable error) {
150
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
151
+ }];
152
+ }
153
+
154
+ RCT_EXPORT_METHOD(cancelTriggerNotifications:
155
+ (RCTPromiseResolveBlock)resolve
156
+ reject:
157
+ (RCTPromiseRejectBlock)reject
158
+ ) {
159
+ [NotifeeCore cancelAllNotifications:kReactNativeNotifeeNotificationTypeTrigger withBlock:^(NSError *_Nullable error) {
160
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
161
+ }];
162
+ }
163
+
164
+ RCT_EXPORT_METHOD(cancelAllNotificationsWithIds:
165
+ (NSArray<NSString *> *)ids
166
+ resolve:
167
+ (RCTPromiseResolveBlock)resolve
168
+ reject:
169
+ (RCTPromiseRejectBlock)reject
170
+ ) {
171
+ [NotifeeCore cancelAllNotificationsWithIds:kReactNativeNotifeeNotificationTypeAll withIds:ids withBlock:^(NSError *_Nullable error) {
172
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
173
+ }];
174
+ }
175
+
176
+
177
+ RCT_EXPORT_METHOD(cancelDisplayedNotificationsWithIds:
178
+ (NSArray<NSString *> *)ids
179
+ resolve:
180
+ (RCTPromiseResolveBlock)resolve
181
+ reject:
182
+ (RCTPromiseRejectBlock)reject
183
+ ) {
184
+ [NotifeeCore cancelAllNotificationsWithIds:kReactNativeNotifeeNotificationTypeDisplayed withIds:ids withBlock:^(NSError *_Nullable error) {
185
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
186
+ }];
187
+ }
188
+
189
+ RCT_EXPORT_METHOD(cancelTriggerNotificationsWithIds:
190
+ (NSArray<NSString *> *)ids
191
+ resolve:
192
+ (RCTPromiseResolveBlock)resolve
193
+ reject:
194
+ (RCTPromiseRejectBlock)reject
195
+ ) {
196
+ [NotifeeCore cancelAllNotificationsWithIds:kReactNativeNotifeeNotificationTypeTrigger withIds:ids withBlock:^(NSError *_Nullable error) {
197
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
198
+ }];
199
+ }
200
+
201
+ RCT_EXPORT_METHOD(getTriggerNotificationIds:
202
+ (RCTPromiseResolveBlock)resolve
203
+ reject:
204
+ (RCTPromiseRejectBlock)reject
205
+ ) {
206
+ [NotifeeCore getTriggerNotificationIds:^(NSError *_Nullable error, NSArray<NSDictionary *> *notifications) {
207
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:notifications];
208
+ }];
209
+ }
210
+
211
+ RCT_EXPORT_METHOD(displayNotification:
212
+ (NSDictionary *) notification
213
+ resolve:
214
+ (RCTPromiseResolveBlock) resolve
215
+ reject:
216
+ (RCTPromiseRejectBlock) reject
217
+ ) {
218
+ [NotifeeCore displayNotification:notification withBlock:^(NSError *_Nullable error) {
219
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
220
+ }];
221
+ }
222
+
223
+ RCT_EXPORT_METHOD(createTriggerNotification:
224
+ (NSDictionary *)notification
225
+ trigger:
226
+ (NSDictionary *)trigger
227
+ resolve:
228
+ (RCTPromiseResolveBlock) resolve
229
+ reject:
230
+ (RCTPromiseRejectBlock) reject) {
231
+ [NotifeeCore createTriggerNotification:notification withTrigger:trigger withBlock:^(NSError *_Nullable error) {
232
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
233
+ }];
234
+ }
235
+
236
+ RCT_EXPORT_METHOD(requestPermission:
237
+ (NSDictionary *) permissions
238
+ resolve:
239
+ (RCTPromiseResolveBlock) resolve
240
+ reject:
241
+ (RCTPromiseRejectBlock) reject
242
+ ) {
243
+ [NotifeeCore requestPermission:permissions withBlock:^(NSError *_Nullable error, NSDictionary *settings) {
244
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:settings];
245
+ }];
246
+ }
247
+
248
+ RCT_EXPORT_METHOD(getNotificationSettings:
249
+ (RCTPromiseResolveBlock) resolve
250
+ reject:
251
+ (RCTPromiseRejectBlock) reject
252
+ ) {
253
+ [NotifeeCore getNotificationSettings:^(NSError *_Nullable error, NSDictionary *settings) {
254
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:settings];
255
+ }];
256
+ }
257
+
258
+ RCT_EXPORT_METHOD(getInitialNotification:
259
+ (RCTPromiseResolveBlock) resolve
260
+ reject:
261
+ (RCTPromiseRejectBlock) reject
262
+ ) {
263
+ [NotifeeCore getInitialNotification:^(NSError *_Nullable error, NSDictionary *settings) {
264
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:settings];
265
+ }];
266
+ }
267
+
268
+ RCT_EXPORT_METHOD(getNotificationCategories:
269
+ (RCTPromiseResolveBlock) resolve
270
+ reject:
271
+ (RCTPromiseRejectBlock) reject
272
+ ) {
273
+ [NotifeeCore getNotificationCategories:^(NSError *_Nullable error, NSArray<NSDictionary *> *categories) {
274
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:categories];
275
+ }];
276
+ }
277
+
278
+ RCT_EXPORT_METHOD(getDisplayedNotifications:
279
+ (RCTPromiseResolveBlock) resolve
280
+ reject:
281
+ (RCTPromiseRejectBlock) reject
282
+ ) {
283
+ [NotifeeCore getDisplayedNotifications:^(NSError *_Nullable error, NSArray<NSDictionary *> *notifications) {
284
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:notifications];
285
+ }];
286
+ }
287
+
288
+ RCT_EXPORT_METHOD(getTriggerNotifications:
289
+ (RCTPromiseResolveBlock) resolve
290
+ reject:
291
+ (RCTPromiseRejectBlock) reject
292
+ ) {
293
+ [NotifeeCore getTriggerNotifications:^(NSError *_Nullable error, NSArray<NSDictionary *> *notifications) {
294
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:notifications];
295
+ }];
296
+ }
297
+
298
+ RCT_EXPORT_METHOD(setNotificationCategories:
299
+ (NSArray<NSDictionary *> *) categories
300
+ resolve:
301
+ (RCTPromiseResolveBlock) resolve
302
+ reject:
303
+ (RCTPromiseRejectBlock) reject
304
+ ) {
305
+ [NotifeeCore setNotificationCategories:categories withBlock:^(NSError *_Nullable error) {
306
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
307
+ }];
308
+ }
309
+
310
+ RCT_EXPORT_METHOD(setBadgeCount:
311
+ (nonnull NSNumber *) count
312
+ resolve:
313
+ (RCTPromiseResolveBlock) resolve
314
+ reject:
315
+ (RCTPromiseRejectBlock) reject
316
+ ) {
317
+ [NotifeeCore setBadgeCount:[count integerValue] withBlock:^(NSError *_Nullable error) {
318
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
319
+ }];
320
+ }
321
+
322
+ RCT_EXPORT_METHOD(getBadgeCount:
323
+ (RCTPromiseResolveBlock) resolve
324
+ reject:
325
+ (RCTPromiseRejectBlock) reject
326
+ ) {
327
+ [NotifeeCore getBadgeCount:^(NSError *_Nullable error, NSInteger count) {
328
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:@(count)];
329
+ }];
330
+ }
331
+
332
+ RCT_EXPORT_METHOD(incrementBadgeCount:
333
+ (nonnull NSNumber *) incrementBy
334
+ resolve:
335
+ (RCTPromiseResolveBlock) resolve
336
+ reject:
337
+ (RCTPromiseRejectBlock) reject
338
+ ) {
339
+ [NotifeeCore incrementBadgeCount:[incrementBy integerValue] withBlock:^(NSError *_Nullable error) {
340
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
341
+ }];
342
+ }
343
+
344
+ RCT_EXPORT_METHOD(decrementBadgeCount:
345
+ (nonnull NSNumber *) decrementBy
346
+ resolve:
347
+ (RCTPromiseResolveBlock) resolve
348
+ reject:
349
+ (RCTPromiseRejectBlock) reject
350
+ ) {
351
+ [NotifeeCore decrementBadgeCount:[decrementBy integerValue] withBlock:^(NSError *_Nullable error) {
352
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
353
+ }];
354
+ }
355
+
356
+ // clang-format on
357
+
358
+ #pragma mark - Internals
359
+
360
+ - (void)resolve:(RCTPromiseResolveBlock)resolve
361
+ orReject:(RCTPromiseRejectBlock)reject
362
+ promiseWithError:(NSError *_Nullable)error
363
+ orResult:(id _Nullable)result {
364
+ if (error != nil) {
365
+ reject(@"unknown", error.localizedDescription, error);
366
+ } else {
367
+ resolve(result);
368
+ }
369
+ }
370
+
371
+ @end
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 || \
19
+ __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_14
20
+ #import <UserNotifications/UserNotifications.h>
21
+ #endif
22
+
23
+ #import "NotifeeCore.h"
24
+
25
+ NS_ASSUME_NONNULL_BEGIN
26
+ @interface NotifeeExtensionHelper : NSObject
27
+
28
+ + (void)populateNotificationContent:(UNNotificationRequest *_Nullable)request
29
+ withContent:(UNMutableNotificationContent *)content
30
+ withContentHandler:(void (^)(UNNotificationContent *_Nonnull))contentHandler;
31
+
32
+ + (void)populateNotificationContent:(UNMutableNotificationContent *)content
33
+ withContentHandler:(void (^)(UNNotificationContent *_Nonnull))contentHandler
34
+ __attribute__((deprecated));
35
+ @end
36
+
37
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ #import "NotifeeExtensionHelper.h"
19
+
20
+ @implementation NotifeeExtensionHelper
21
+
22
+ + (void)populateNotificationContent:(UNNotificationRequest *)request
23
+ withContent:(UNMutableNotificationContent *)content
24
+ withContentHandler:(void (^)(UNNotificationContent *_Nonnull))contentHandler {
25
+ [NotifeeCore populateNotificationContent:request
26
+ withContent:content
27
+ withContentHandler:contentHandler];
28
+ };
29
+
30
+ + (void)populateNotificationContent:(UNMutableNotificationContent *)content
31
+ withContentHandler:(void (^)(UNNotificationContent *_Nonnull))contentHandler {
32
+ [NotifeeExtensionHelper populateNotificationContent:nil
33
+ withContent:content
34
+ withContentHandler:contentHandler];
35
+ };
36
+
37
+ @end