react-native-notify-kit 9.1.8

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 (212) hide show
  1. package/LICENSE +44 -0
  2. package/README.md +212 -0
  3. package/RNNotifee.podspec +37 -0
  4. package/RNNotifeeCore.podspec +32 -0
  5. package/android/.editorconfig +10 -0
  6. package/android/build.gradle +117 -0
  7. package/android/gradle.properties +1 -0
  8. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar +0 -0
  9. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.md5 +1 -0
  10. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha1 +1 -0
  11. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha256 +1 -0
  12. package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha512 +1 -0
  13. package/android/libs/app/notifee/core/202108261754/core-202108261754.pom +9 -0
  14. package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.md5 +1 -0
  15. package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.sha1 +1 -0
  16. package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.sha256 +1 -0
  17. package/android/libs/app/notifee/core/202108261754/core-202108261754.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 +82 -0
  25. package/android/settings.gradle +1 -0
  26. package/android/src/main/AndroidManifest.xml +12 -0
  27. package/android/src/main/kotlin/io/invertase/notifee/HeadlessTask.kt +257 -0
  28. package/android/src/main/kotlin/io/invertase/notifee/NotifeeApiModule.kt +392 -0
  29. package/android/src/main/kotlin/io/invertase/notifee/NotifeeEventSubscriber.kt +117 -0
  30. package/android/src/main/kotlin/io/invertase/notifee/NotifeeInitProvider.kt +43 -0
  31. package/android/src/main/kotlin/io/invertase/notifee/NotifeePackage.kt +37 -0
  32. package/android/src/main/kotlin/io/invertase/notifee/NotifeeReactUtils.kt +118 -0
  33. package/dist/NotifeeApiModule.d.ts +53 -0
  34. package/dist/NotifeeApiModule.js +593 -0
  35. package/dist/NotifeeApiModule.js.map +1 -0
  36. package/dist/NotifeeJSEventEmitter.d.ts +3 -0
  37. package/dist/NotifeeJSEventEmitter.js +9 -0
  38. package/dist/NotifeeJSEventEmitter.js.map +1 -0
  39. package/dist/NotifeeNativeError.d.ts +15 -0
  40. package/dist/NotifeeNativeError.js +56 -0
  41. package/dist/NotifeeNativeError.js.map +1 -0
  42. package/dist/NotifeeNativeModule.d.ts +13 -0
  43. package/dist/NotifeeNativeModule.js +27 -0
  44. package/dist/NotifeeNativeModule.js.map +1 -0
  45. package/dist/NotifeeNativeModule.web.d.ts +12 -0
  46. package/dist/NotifeeNativeModule.web.js +15 -0
  47. package/dist/NotifeeNativeModule.web.js.map +1 -0
  48. package/dist/index.d.ts +8 -0
  49. package/dist/index.js +24 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/specs/NativeNotifeeModule.d.ts +53 -0
  52. package/dist/specs/NativeNotifeeModule.js +6 -0
  53. package/dist/specs/NativeNotifeeModule.js.map +1 -0
  54. package/dist/types/Library.d.ts +21 -0
  55. package/dist/types/Library.js +5 -0
  56. package/dist/types/Library.js.map +1 -0
  57. package/dist/types/Module.d.ts +576 -0
  58. package/dist/types/Module.js +5 -0
  59. package/dist/types/Module.js.map +1 -0
  60. package/dist/types/Notification.d.ts +462 -0
  61. package/dist/types/Notification.js +108 -0
  62. package/dist/types/Notification.js.map +1 -0
  63. package/dist/types/NotificationAndroid.d.ts +1311 -0
  64. package/dist/types/NotificationAndroid.js +406 -0
  65. package/dist/types/NotificationAndroid.js.map +1 -0
  66. package/dist/types/NotificationIOS.d.ts +539 -0
  67. package/dist/types/NotificationIOS.js +89 -0
  68. package/dist/types/NotificationIOS.js.map +1 -0
  69. package/dist/types/NotificationWeb.d.ts +5 -0
  70. package/dist/types/NotificationWeb.js +5 -0
  71. package/dist/types/NotificationWeb.js.map +1 -0
  72. package/dist/types/PowerManagerInfo.d.ts +36 -0
  73. package/dist/types/PowerManagerInfo.js +5 -0
  74. package/dist/types/PowerManagerInfo.js.map +1 -0
  75. package/dist/types/Trigger.d.ts +124 -0
  76. package/dist/types/Trigger.js +48 -0
  77. package/dist/types/Trigger.js.map +1 -0
  78. package/dist/utils/id.d.ts +1 -0
  79. package/dist/utils/id.js +12 -0
  80. package/dist/utils/id.js.map +1 -0
  81. package/dist/utils/index.d.ts +16 -0
  82. package/dist/utils/index.js +31 -0
  83. package/dist/utils/index.js.map +1 -0
  84. package/dist/utils/validate.d.ts +15 -0
  85. package/dist/utils/validate.js +75 -0
  86. package/dist/utils/validate.js.map +1 -0
  87. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.d.ts +2 -0
  88. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js +45 -0
  89. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js.map +1 -0
  90. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.d.ts +2 -0
  91. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js +24 -0
  92. package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js.map +1 -0
  93. package/dist/validators/validate.d.ts +25 -0
  94. package/dist/validators/validate.js +68 -0
  95. package/dist/validators/validate.js.map +1 -0
  96. package/dist/validators/validateAndroidAction.d.ts +2 -0
  97. package/dist/validators/validateAndroidAction.js +46 -0
  98. package/dist/validators/validateAndroidAction.js.map +1 -0
  99. package/dist/validators/validateAndroidChannel.d.ts +2 -0
  100. package/dist/validators/validateAndroidChannel.js +152 -0
  101. package/dist/validators/validateAndroidChannel.js.map +1 -0
  102. package/dist/validators/validateAndroidChannelGroup.d.ts +2 -0
  103. package/dist/validators/validateAndroidChannelGroup.js +39 -0
  104. package/dist/validators/validateAndroidChannelGroup.js.map +1 -0
  105. package/dist/validators/validateAndroidFullScreenAction.d.ts +2 -0
  106. package/dist/validators/validateAndroidFullScreenAction.js +47 -0
  107. package/dist/validators/validateAndroidFullScreenAction.js.map +1 -0
  108. package/dist/validators/validateAndroidInput.d.ts +2 -0
  109. package/dist/validators/validateAndroidInput.js +51 -0
  110. package/dist/validators/validateAndroidInput.js.map +1 -0
  111. package/dist/validators/validateAndroidNotification.d.ts +2 -0
  112. package/dist/validators/validateAndroidNotification.js +541 -0
  113. package/dist/validators/validateAndroidNotification.js.map +1 -0
  114. package/dist/validators/validateAndroidPressAction.d.ts +2 -0
  115. package/dist/validators/validateAndroidPressAction.js +47 -0
  116. package/dist/validators/validateAndroidPressAction.js.map +1 -0
  117. package/dist/validators/validateAndroidStyle.d.ts +22 -0
  118. package/dist/validators/validateAndroidStyle.js +222 -0
  119. package/dist/validators/validateAndroidStyle.js.map +1 -0
  120. package/dist/validators/validateIOSAttachment.d.ts +6 -0
  121. package/dist/validators/validateIOSAttachment.js +96 -0
  122. package/dist/validators/validateIOSAttachment.js.map +1 -0
  123. package/dist/validators/validateIOSCategory.d.ts +2 -0
  124. package/dist/validators/validateIOSCategory.js +118 -0
  125. package/dist/validators/validateIOSCategory.js.map +1 -0
  126. package/dist/validators/validateIOSCategoryAction.d.ts +2 -0
  127. package/dist/validators/validateIOSCategoryAction.js +53 -0
  128. package/dist/validators/validateIOSCategoryAction.js.map +1 -0
  129. package/dist/validators/validateIOSInput.d.ts +2 -0
  130. package/dist/validators/validateIOSInput.js +29 -0
  131. package/dist/validators/validateIOSInput.js.map +1 -0
  132. package/dist/validators/validateIOSNotification.d.ts +2 -0
  133. package/dist/validators/validateIOSNotification.js +205 -0
  134. package/dist/validators/validateIOSNotification.js.map +1 -0
  135. package/dist/validators/validateIOSPermissions.d.ts +2 -0
  136. package/dist/validators/validateIOSPermissions.js +59 -0
  137. package/dist/validators/validateIOSPermissions.js.map +1 -0
  138. package/dist/validators/validateNotification.d.ts +11 -0
  139. package/dist/validators/validateNotification.js +121 -0
  140. package/dist/validators/validateNotification.js.map +1 -0
  141. package/dist/validators/validateTrigger.d.ts +2 -0
  142. package/dist/validators/validateTrigger.js +107 -0
  143. package/dist/validators/validateTrigger.js.map +1 -0
  144. package/dist/version.d.ts +1 -0
  145. package/dist/version.js +3 -0
  146. package/dist/version.js.map +1 -0
  147. package/ios/NotifeeCore/Info.plist +22 -0
  148. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.h +28 -0
  149. package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m +76 -0
  150. package/ios/NotifeeCore/NotifeeCore+NSURLSession.h +25 -0
  151. package/ios/NotifeeCore/NotifeeCore+NSURLSession.m +55 -0
  152. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.h +44 -0
  153. package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +270 -0
  154. package/ios/NotifeeCore/NotifeeCore.h +118 -0
  155. package/ios/NotifeeCore/NotifeeCore.m +843 -0
  156. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.h +34 -0
  157. package/ios/NotifeeCore/NotifeeCoreDelegateHolder.m +70 -0
  158. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.h +39 -0
  159. package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.m +68 -0
  160. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.h +38 -0
  161. package/ios/NotifeeCore/NotifeeCoreExtensionHelper.m +224 -0
  162. package/ios/NotifeeCore/NotifeeCoreUtil.h +81 -0
  163. package/ios/NotifeeCore/NotifeeCoreUtil.m +834 -0
  164. package/ios/RNNotifee/NotifeeApiModule.h +25 -0
  165. package/ios/RNNotifee/NotifeeApiModule.mm +421 -0
  166. package/ios/RNNotifee/NotifeeExtensionHelper.h +37 -0
  167. package/ios/RNNotifee/NotifeeExtensionHelper.m +37 -0
  168. package/ios/RNNotifee.xcodeproj/project.pbxproj +318 -0
  169. package/ios/RNNotifee.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  170. package/ios/RNNotifee.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  171. package/jest-mock.js +162 -0
  172. package/package.json +85 -0
  173. package/react-native.config.js +11 -0
  174. package/src/NotifeeApiModule.ts +823 -0
  175. package/src/NotifeeJSEventEmitter.ts +10 -0
  176. package/src/NotifeeNativeError.ts +68 -0
  177. package/src/NotifeeNativeModule.ts +39 -0
  178. package/src/NotifeeNativeModule.web.ts +25 -0
  179. package/src/index.ts +33 -0
  180. package/src/specs/NativeNotifeeModule.ts +71 -0
  181. package/src/types/Library.ts +28 -0
  182. package/src/types/Module.ts +629 -0
  183. package/src/types/Notification.ts +518 -0
  184. package/src/types/NotificationAndroid.ts +1478 -0
  185. package/src/types/NotificationIOS.ts +683 -0
  186. package/src/types/NotificationWeb.ts +5 -0
  187. package/src/types/PowerManagerInfo.ts +43 -0
  188. package/src/types/Trigger.ts +136 -0
  189. package/src/utils/id.ts +13 -0
  190. package/src/utils/index.ts +46 -0
  191. package/src/utils/validate.ts +90 -0
  192. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfo.ts +61 -0
  193. package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.ts +33 -0
  194. package/src/validators/validate.ts +85 -0
  195. package/src/validators/validateAndroidAction.ts +54 -0
  196. package/src/validators/validateAndroidChannel.ts +188 -0
  197. package/src/validators/validateAndroidChannelGroup.ts +49 -0
  198. package/src/validators/validateAndroidFullScreenAction.ts +65 -0
  199. package/src/validators/validateAndroidInput.ts +67 -0
  200. package/src/validators/validateAndroidNotification.ts +734 -0
  201. package/src/validators/validateAndroidPressAction.ts +65 -0
  202. package/src/validators/validateAndroidStyle.ts +315 -0
  203. package/src/validators/validateIOSAttachment.ts +135 -0
  204. package/src/validators/validateIOSCategory.ts +150 -0
  205. package/src/validators/validateIOSCategoryAction.ts +65 -0
  206. package/src/validators/validateIOSInput.ts +38 -0
  207. package/src/validators/validateIOSNotification.ts +296 -0
  208. package/src/validators/validateIOSPermissions.ts +78 -0
  209. package/src/validators/validateNotification.ts +156 -0
  210. package/src/validators/validateTrigger.ts +142 -0
  211. package/src/version.ts +2 -0
  212. package/tsconfig.json +27 -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 <NotifeeSpec/NotifeeSpec.h>
20
+ #import <React/RCTEventEmitter.h>
21
+ #import "NotifeeCore.h"
22
+
23
+ @interface NotifeeApiModule : RCTEventEmitter <NativeNotifeeModuleSpec, NotifeeCoreDelegate>
24
+
25
+ @end
@@ -0,0 +1,421 @@
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
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
72
+ (const facebook::react::ObjCTurboModule::InitParams &)params {
73
+ return std::make_shared<facebook::react::NativeNotifeeModuleSpecJSI>(params);
74
+ }
75
+
76
+ - (NSDictionary *)getConstants {
77
+ return @{@"ANDROID_API_LEVEL" : @0};
78
+ }
79
+
80
+ #pragma mark - Events
81
+
82
+ - (void)didReceiveNotifeeCoreEvent:(NSDictionary *_Nonnull)event {
83
+ if (hasListeners) {
84
+ [self sendNotifeeCoreEvent:event];
85
+ } else {
86
+ [pendingCoreEvents addObject:event];
87
+ }
88
+ }
89
+
90
+ - (void)sendNotifeeCoreEvent:(NSDictionary *_Nonnull)eventBody {
91
+ dispatch_after(
92
+ dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
93
+ if (RCTRunningInAppExtension() ||
94
+ [UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
95
+ [self sendEventWithName:kReactNativeNotifeeNotificationBackgroundEvent body:eventBody];
96
+ } else {
97
+ [self sendEventWithName:kReactNativeNotifeeNotificationEvent body:eventBody];
98
+ }
99
+ });
100
+ }
101
+
102
+ // clang-format off
103
+
104
+ #pragma mark - Shared Methods
105
+
106
+ - (void)cancelAllNotifications:(RCTPromiseResolveBlock)resolve
107
+ reject:(RCTPromiseRejectBlock)reject {
108
+ [NotifeeCore cancelAllNotifications:kReactNativeNotifeeNotificationTypeAll withBlock:^(NSError *_Nullable error) {
109
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
110
+ }];
111
+ }
112
+
113
+ - (void)cancelDisplayedNotifications:(RCTPromiseResolveBlock)resolve
114
+ reject:(RCTPromiseRejectBlock)reject {
115
+ [NotifeeCore cancelAllNotifications:kReactNativeNotifeeNotificationTypeDisplayed withBlock:^(NSError *_Nullable error) {
116
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
117
+ }];
118
+ }
119
+
120
+ - (void)cancelTriggerNotifications:(RCTPromiseResolveBlock)resolve
121
+ reject:(RCTPromiseRejectBlock)reject {
122
+ [NotifeeCore cancelAllNotifications:kReactNativeNotifeeNotificationTypeTrigger withBlock:^(NSError *_Nullable error) {
123
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
124
+ }];
125
+ }
126
+
127
+ - (void)cancelAllNotificationsWithIds:(NSArray *)ids
128
+ notificationType:(double)notificationType
129
+ tag:(NSString *_Nullable)tag
130
+ resolve:(RCTPromiseResolveBlock)resolve
131
+ reject:(RCTPromiseRejectBlock)reject {
132
+ // tag is Android-only, ignored on iOS
133
+ [NotifeeCore cancelAllNotificationsWithIds:(NSInteger)notificationType withIds:ids withBlock:^(NSError *_Nullable error) {
134
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
135
+ }];
136
+ }
137
+
138
+ - (void)getDisplayedNotifications:(RCTPromiseResolveBlock)resolve
139
+ reject:(RCTPromiseRejectBlock)reject {
140
+ [NotifeeCore getDisplayedNotifications:^(NSError *_Nullable error, NSArray<NSDictionary *> *notifications) {
141
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:notifications];
142
+ }];
143
+ }
144
+
145
+ - (void)getTriggerNotifications:(RCTPromiseResolveBlock)resolve
146
+ reject:(RCTPromiseRejectBlock)reject {
147
+ [NotifeeCore getTriggerNotifications:^(NSError *_Nullable error, NSArray<NSDictionary *> *notifications) {
148
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:notifications];
149
+ }];
150
+ }
151
+
152
+ - (void)getTriggerNotificationIds:(RCTPromiseResolveBlock)resolve
153
+ reject:(RCTPromiseRejectBlock)reject {
154
+ [NotifeeCore getTriggerNotificationIds:^(NSError *_Nullable error, NSArray<NSDictionary *> *notifications) {
155
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:notifications];
156
+ }];
157
+ }
158
+
159
+ - (void)displayNotification:(NSDictionary *)notification
160
+ resolve:(RCTPromiseResolveBlock)resolve
161
+ reject:(RCTPromiseRejectBlock)reject {
162
+ [NotifeeCore displayNotification:notification withBlock:^(NSError *_Nullable error) {
163
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
164
+ }];
165
+ }
166
+
167
+ - (void)createTriggerNotification:(NSDictionary *)notification
168
+ trigger:(NSDictionary *)trigger
169
+ resolve:(RCTPromiseResolveBlock)resolve
170
+ reject:(RCTPromiseRejectBlock)reject {
171
+ [NotifeeCore createTriggerNotification:notification withTrigger:trigger withBlock:^(NSError *_Nullable error) {
172
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
173
+ }];
174
+ }
175
+
176
+ - (void)requestPermission:(NSDictionary *)permissions
177
+ resolve:(RCTPromiseResolveBlock)resolve
178
+ reject:(RCTPromiseRejectBlock)reject {
179
+ [NotifeeCore requestPermission:permissions withBlock:^(NSError *_Nullable error, NSDictionary *settings) {
180
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:settings];
181
+ }];
182
+ }
183
+
184
+ - (void)getNotificationSettings:(RCTPromiseResolveBlock)resolve
185
+ reject:(RCTPromiseRejectBlock)reject {
186
+ [NotifeeCore getNotificationSettings:^(NSError *_Nullable error, NSDictionary *settings) {
187
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:settings];
188
+ }];
189
+ }
190
+
191
+ - (void)getInitialNotification:(RCTPromiseResolveBlock)resolve
192
+ reject:(RCTPromiseRejectBlock)reject {
193
+ [NotifeeCore getInitialNotification:^(NSError *_Nullable error, NSDictionary *notification) {
194
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:notification];
195
+ }];
196
+ }
197
+
198
+ #pragma mark - iOS-only Methods
199
+
200
+ - (void)cancelNotification:(NSString *)notificationId
201
+ resolve:(RCTPromiseResolveBlock)resolve
202
+ reject:(RCTPromiseRejectBlock)reject {
203
+ [NotifeeCore cancelNotification:notificationId withNotificationType:kReactNativeNotifeeNotificationTypeAll withBlock:^(NSError *_Nullable error) {
204
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
205
+ }];
206
+ }
207
+
208
+ - (void)cancelDisplayedNotification:(NSString *)notificationId
209
+ resolve:(RCTPromiseResolveBlock)resolve
210
+ reject:(RCTPromiseRejectBlock)reject {
211
+ [NotifeeCore cancelNotification:notificationId withNotificationType:kReactNativeNotifeeNotificationTypeDisplayed withBlock:^(NSError *_Nullable error) {
212
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
213
+ }];
214
+ }
215
+
216
+ - (void)cancelTriggerNotification:(NSString *)notificationId
217
+ resolve:(RCTPromiseResolveBlock)resolve
218
+ reject:(RCTPromiseRejectBlock)reject {
219
+ [NotifeeCore cancelNotification:notificationId withNotificationType:kReactNativeNotifeeNotificationTypeTrigger withBlock:^(NSError *_Nullable error) {
220
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
221
+ }];
222
+ }
223
+
224
+ - (void)cancelDisplayedNotificationsWithIds:(NSArray *)ids
225
+ resolve:(RCTPromiseResolveBlock)resolve
226
+ reject:(RCTPromiseRejectBlock)reject {
227
+ [NotifeeCore cancelAllNotificationsWithIds:kReactNativeNotifeeNotificationTypeDisplayed withIds:ids withBlock:^(NSError *_Nullable error) {
228
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
229
+ }];
230
+ }
231
+
232
+ - (void)cancelTriggerNotificationsWithIds:(NSArray *)ids
233
+ resolve:(RCTPromiseResolveBlock)resolve
234
+ reject:(RCTPromiseRejectBlock)reject {
235
+ [NotifeeCore cancelAllNotificationsWithIds:kReactNativeNotifeeNotificationTypeTrigger withIds:ids withBlock:^(NSError *_Nullable error) {
236
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
237
+ }];
238
+ }
239
+
240
+ - (void)getNotificationCategories:(RCTPromiseResolveBlock)resolve
241
+ reject:(RCTPromiseRejectBlock)reject {
242
+ [NotifeeCore getNotificationCategories:^(NSError *_Nullable error, NSArray<NSDictionary *> *categories) {
243
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:categories];
244
+ }];
245
+ }
246
+
247
+ - (void)setNotificationCategories:(NSArray *)categories
248
+ resolve:(RCTPromiseResolveBlock)resolve
249
+ reject:(RCTPromiseRejectBlock)reject {
250
+ [NotifeeCore setNotificationCategories:categories withBlock:^(NSError *_Nullable error) {
251
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
252
+ }];
253
+ }
254
+
255
+ - (void)setBadgeCount:(double)count
256
+ resolve:(RCTPromiseResolveBlock)resolve
257
+ reject:(RCTPromiseRejectBlock)reject {
258
+ [NotifeeCore setBadgeCount:(NSInteger)count withBlock:^(NSError *_Nullable error) {
259
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
260
+ }];
261
+ }
262
+
263
+ - (void)getBadgeCount:(RCTPromiseResolveBlock)resolve
264
+ reject:(RCTPromiseRejectBlock)reject {
265
+ [NotifeeCore getBadgeCount:^(NSError *_Nullable error, NSInteger count) {
266
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:@(count)];
267
+ }];
268
+ }
269
+
270
+ - (void)incrementBadgeCount:(double)incrementBy
271
+ resolve:(RCTPromiseResolveBlock)resolve
272
+ reject:(RCTPromiseRejectBlock)reject {
273
+ [NotifeeCore incrementBadgeCount:(NSInteger)incrementBy withBlock:^(NSError *_Nullable error) {
274
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
275
+ }];
276
+ }
277
+
278
+ - (void)decrementBadgeCount:(double)decrementBy
279
+ resolve:(RCTPromiseResolveBlock)resolve
280
+ reject:(RCTPromiseRejectBlock)reject {
281
+ [NotifeeCore decrementBadgeCount:(NSInteger)decrementBy withBlock:^(NSError *_Nullable error) {
282
+ [self resolve:resolve orReject:reject promiseWithError:error orResult:nil];
283
+ }];
284
+ }
285
+
286
+ #pragma mark - Android-only stubs (required by NativeNotifeeModuleSpec)
287
+
288
+ - (void)createChannel:(NSDictionary *)channelMap
289
+ resolve:(RCTPromiseResolveBlock)resolve
290
+ reject:(RCTPromiseRejectBlock)reject {
291
+ resolve(nil);
292
+ }
293
+
294
+ - (void)createChannels:(NSArray *)channelsArray
295
+ resolve:(RCTPromiseResolveBlock)resolve
296
+ reject:(RCTPromiseRejectBlock)reject {
297
+ resolve(nil);
298
+ }
299
+
300
+ - (void)createChannelGroup:(NSDictionary *)channelGroupMap
301
+ resolve:(RCTPromiseResolveBlock)resolve
302
+ reject:(RCTPromiseRejectBlock)reject {
303
+ resolve(nil);
304
+ }
305
+
306
+ - (void)createChannelGroups:(NSArray *)channelGroupsArray
307
+ resolve:(RCTPromiseResolveBlock)resolve
308
+ reject:(RCTPromiseRejectBlock)reject {
309
+ resolve(nil);
310
+ }
311
+
312
+ - (void)deleteChannel:(NSString *)channelId
313
+ resolve:(RCTPromiseResolveBlock)resolve
314
+ reject:(RCTPromiseRejectBlock)reject {
315
+ resolve(nil);
316
+ }
317
+
318
+ - (void)deleteChannelGroup:(NSString *)channelGroupId
319
+ resolve:(RCTPromiseResolveBlock)resolve
320
+ reject:(RCTPromiseRejectBlock)reject {
321
+ resolve(nil);
322
+ }
323
+
324
+ - (void)getChannel:(NSString *)channelId
325
+ resolve:(RCTPromiseResolveBlock)resolve
326
+ reject:(RCTPromiseRejectBlock)reject {
327
+ resolve(nil);
328
+ }
329
+
330
+ - (void)getChannels:(RCTPromiseResolveBlock)resolve
331
+ reject:(RCTPromiseRejectBlock)reject {
332
+ resolve(nil);
333
+ }
334
+
335
+ - (void)getChannelGroup:(NSString *)channelGroupId
336
+ resolve:(RCTPromiseResolveBlock)resolve
337
+ reject:(RCTPromiseRejectBlock)reject {
338
+ resolve(nil);
339
+ }
340
+
341
+ - (void)getChannelGroups:(RCTPromiseResolveBlock)resolve
342
+ reject:(RCTPromiseRejectBlock)reject {
343
+ resolve(nil);
344
+ }
345
+
346
+ - (void)isChannelCreated:(NSString *)channelId
347
+ resolve:(RCTPromiseResolveBlock)resolve
348
+ reject:(RCTPromiseRejectBlock)reject {
349
+ resolve(@(NO));
350
+ }
351
+
352
+ - (void)isChannelBlocked:(NSString *)channelId
353
+ resolve:(RCTPromiseResolveBlock)resolve
354
+ reject:(RCTPromiseRejectBlock)reject {
355
+ resolve(@(NO));
356
+ }
357
+
358
+ - (void)openAlarmPermissionSettings:(RCTPromiseResolveBlock)resolve
359
+ reject:(RCTPromiseRejectBlock)reject {
360
+ resolve(nil);
361
+ }
362
+
363
+ - (void)openNotificationSettings:(NSString *_Nullable)channelId
364
+ resolve:(RCTPromiseResolveBlock)resolve
365
+ reject:(RCTPromiseRejectBlock)reject {
366
+ resolve(nil);
367
+ }
368
+
369
+ - (void)openBatteryOptimizationSettings:(RCTPromiseResolveBlock)resolve
370
+ reject:(RCTPromiseRejectBlock)reject {
371
+ resolve(nil);
372
+ }
373
+
374
+ - (void)isBatteryOptimizationEnabled:(RCTPromiseResolveBlock)resolve
375
+ reject:(RCTPromiseRejectBlock)reject {
376
+ resolve(@(NO));
377
+ }
378
+
379
+ - (void)getPowerManagerInfo:(RCTPromiseResolveBlock)resolve
380
+ reject:(RCTPromiseRejectBlock)reject {
381
+ resolve(@{});
382
+ }
383
+
384
+ - (void)openPowerManagerSettings:(RCTPromiseResolveBlock)resolve
385
+ reject:(RCTPromiseRejectBlock)reject {
386
+ resolve(nil);
387
+ }
388
+
389
+ - (void)stopForegroundService:(RCTPromiseResolveBlock)resolve
390
+ reject:(RCTPromiseRejectBlock)reject {
391
+ resolve(nil);
392
+ }
393
+
394
+ - (void)hideNotificationDrawer {
395
+ // Android-only, no-op on iOS
396
+ }
397
+
398
+ - (void)addListener:(NSString *)eventName {
399
+ [super addListener:eventName];
400
+ }
401
+
402
+ - (void)removeListeners:(double)count {
403
+ [super removeListeners:count];
404
+ }
405
+
406
+ // clang-format on
407
+
408
+ #pragma mark - Internals
409
+
410
+ - (void)resolve:(RCTPromiseResolveBlock)resolve
411
+ orReject:(RCTPromiseRejectBlock)reject
412
+ promiseWithError:(NSError *_Nullable)error
413
+ orResult:(id _Nullable)result {
414
+ if (error != nil) {
415
+ reject(@"unknown", error.localizedDescription, error);
416
+ } else {
417
+ resolve(result);
418
+ }
419
+ }
420
+
421
+ @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