@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.
- package/.gitattributes +3 -0
- package/LICENSE +44 -0
- package/README.md +131 -0
- package/RNNotifee.podspec +39 -0
- package/RNNotifeeCore.podspec +33 -0
- package/android/build.gradle +116 -0
- package/android/gradle.properties +1 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar +0 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.md5 +1 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha1 +1 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha256 +1 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.aar.sha512 +1 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom +9 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.md5 +1 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha1 +1 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha256 +1 -0
- package/android/libs/app/notifee/core/202108261756/core-202108261756.pom.sha512 +1 -0
- package/android/libs/app/notifee/core/maven-metadata.xml +13 -0
- package/android/libs/app/notifee/core/maven-metadata.xml.md5 +1 -0
- package/android/libs/app/notifee/core/maven-metadata.xml.sha1 +1 -0
- package/android/libs/app/notifee/core/maven-metadata.xml.sha256 +1 -0
- package/android/libs/app/notifee/core/maven-metadata.xml.sha512 +1 -0
- package/android/lint.xml +5 -0
- package/android/proguard-rules.pro +74 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +12 -0
- package/android/src/main/java/io/invertase/notifee/NotifeeApiModule.java +349 -0
- package/android/src/main/java/io/invertase/notifee/NotifeeEventSubscriber.java +118 -0
- package/android/src/main/java/io/invertase/notifee/NotifeeInitProvider.java +55 -0
- package/android/src/main/java/io/invertase/notifee/NotifeePackage.java +30 -0
- package/android/src/main/java/io/invertase/notifee/NotifeeReactUtils.java +244 -0
- package/app.plugin.js +1 -0
- package/dist/NotifeeApiModule.d.ts +53 -0
- package/dist/NotifeeApiModule.js +607 -0
- package/dist/NotifeeApiModule.js.map +1 -0
- package/dist/NotifeeJSEventEmitter.d.ts +3 -0
- package/dist/NotifeeJSEventEmitter.js +14 -0
- package/dist/NotifeeJSEventEmitter.js.map +1 -0
- package/dist/NotifeeNativeError.d.ts +15 -0
- package/dist/NotifeeNativeError.js +61 -0
- package/dist/NotifeeNativeError.js.map +1 -0
- package/dist/NotifeeNativeModule.d.ts +14 -0
- package/dist/NotifeeNativeModule.js +43 -0
- package/dist/NotifeeNativeModule.js.map +1 -0
- package/dist/NotifeeNativeModule.web.d.ts +12 -0
- package/dist/NotifeeNativeModule.web.js +19 -0
- package/dist/NotifeeNativeModule.web.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/types/Library.d.ts +21 -0
- package/dist/types/Library.js +6 -0
- package/dist/types/Library.js.map +1 -0
- package/dist/types/Module.d.ts +572 -0
- package/dist/types/Module.js +6 -0
- package/dist/types/Module.js.map +1 -0
- package/dist/types/Notification.d.ts +450 -0
- package/dist/types/Notification.js +105 -0
- package/dist/types/Notification.js.map +1 -0
- package/dist/types/NotificationAndroid.d.ts +1276 -0
- package/dist/types/NotificationAndroid.js +380 -0
- package/dist/types/NotificationAndroid.js.map +1 -0
- package/dist/types/NotificationIOS.d.ts +537 -0
- package/dist/types/NotificationIOS.js +92 -0
- package/dist/types/NotificationIOS.js.map +1 -0
- package/dist/types/NotificationWeb.d.ts +5 -0
- package/dist/types/NotificationWeb.js +3 -0
- package/dist/types/NotificationWeb.js.map +1 -0
- package/dist/types/PowerManagerInfo.d.ts +36 -0
- package/dist/types/PowerManagerInfo.js +6 -0
- package/dist/types/PowerManagerInfo.js.map +1 -0
- package/dist/types/Trigger.d.ts +108 -0
- package/dist/types/Trigger.js +39 -0
- package/dist/types/Trigger.js.map +1 -0
- package/dist/utils/id.d.ts +1 -0
- package/dist/utils/id.js +16 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/utils/index.d.ts +16 -0
- package/dist/utils/index.js +52 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validate.d.ts +15 -0
- package/dist/utils/validate.js +93 -0
- package/dist/utils/validate.js.map +1 -0
- package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.d.ts +2 -0
- package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js +39 -0
- package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js.map +1 -0
- package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.d.ts +2 -0
- package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js +27 -0
- package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js.map +1 -0
- package/dist/validators/validate.d.ts +25 -0
- package/dist/validators/validate.js +75 -0
- package/dist/validators/validate.js.map +1 -0
- package/dist/validators/validateAndroidAction.d.ts +2 -0
- package/dist/validators/validateAndroidAction.js +52 -0
- package/dist/validators/validateAndroidAction.js.map +1 -0
- package/dist/validators/validateAndroidChannel.d.ts +2 -0
- package/dist/validators/validateAndroidChannel.js +155 -0
- package/dist/validators/validateAndroidChannel.js.map +1 -0
- package/dist/validators/validateAndroidChannelGroup.d.ts +2 -0
- package/dist/validators/validateAndroidChannelGroup.js +42 -0
- package/dist/validators/validateAndroidChannelGroup.js.map +1 -0
- package/dist/validators/validateAndroidFullScreenAction.d.ts +2 -0
- package/dist/validators/validateAndroidFullScreenAction.js +50 -0
- package/dist/validators/validateAndroidFullScreenAction.js.map +1 -0
- package/dist/validators/validateAndroidInput.d.ts +2 -0
- package/dist/validators/validateAndroidInput.js +54 -0
- package/dist/validators/validateAndroidInput.js.map +1 -0
- package/dist/validators/validateAndroidNotification.d.ts +2 -0
- package/dist/validators/validateAndroidNotification.js +529 -0
- package/dist/validators/validateAndroidNotification.js.map +1 -0
- package/dist/validators/validateAndroidPressAction.d.ts +2 -0
- package/dist/validators/validateAndroidPressAction.js +50 -0
- package/dist/validators/validateAndroidPressAction.js.map +1 -0
- package/dist/validators/validateAndroidStyle.d.ts +22 -0
- package/dist/validators/validateAndroidStyle.js +231 -0
- package/dist/validators/validateAndroidStyle.js.map +1 -0
- package/dist/validators/validateIOSAttachment.d.ts +6 -0
- package/dist/validators/validateIOSAttachment.js +102 -0
- package/dist/validators/validateIOSAttachment.js.map +1 -0
- package/dist/validators/validateIOSCategory.d.ts +2 -0
- package/dist/validators/validateIOSCategory.js +124 -0
- package/dist/validators/validateIOSCategory.js.map +1 -0
- package/dist/validators/validateIOSCategoryAction.d.ts +2 -0
- package/dist/validators/validateIOSCategoryAction.js +59 -0
- package/dist/validators/validateIOSCategoryAction.js.map +1 -0
- package/dist/validators/validateIOSInput.d.ts +2 -0
- package/dist/validators/validateIOSInput.js +32 -0
- package/dist/validators/validateIOSInput.js.map +1 -0
- package/dist/validators/validateIOSNotification.d.ts +2 -0
- package/dist/validators/validateIOSNotification.js +211 -0
- package/dist/validators/validateIOSNotification.js.map +1 -0
- package/dist/validators/validateIOSPermissions.d.ts +2 -0
- package/dist/validators/validateIOSPermissions.js +62 -0
- package/dist/validators/validateIOSPermissions.js.map +1 -0
- package/dist/validators/validateNotification.d.ts +11 -0
- package/dist/validators/validateNotification.js +129 -0
- package/dist/validators/validateNotification.js.map +1 -0
- package/dist/validators/validateTrigger.d.ts +2 -0
- package/dist/validators/validateTrigger.js +104 -0
- package/dist/validators/validateTrigger.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js.map +1 -0
- package/ios/NotifeeCore/Info.plist +22 -0
- package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.h +28 -0
- package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m +72 -0
- package/ios/NotifeeCore/NotifeeCore+NSURLSession.h +25 -0
- package/ios/NotifeeCore/NotifeeCore+NSURLSession.m +55 -0
- package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.h +37 -0
- package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +242 -0
- package/ios/NotifeeCore/NotifeeCore.h +118 -0
- package/ios/NotifeeCore/NotifeeCore.m +784 -0
- package/ios/NotifeeCore/NotifeeCoreDelegateHolder.h +34 -0
- package/ios/NotifeeCore/NotifeeCoreDelegateHolder.m +70 -0
- package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.h +39 -0
- package/ios/NotifeeCore/NotifeeCoreDownloadDelegate.m +68 -0
- package/ios/NotifeeCore/NotifeeCoreExtensionHelper.h +38 -0
- package/ios/NotifeeCore/NotifeeCoreExtensionHelper.m +224 -0
- package/ios/NotifeeCore/NotifeeCoreUtil.h +82 -0
- package/ios/NotifeeCore/NotifeeCoreUtil.m +793 -0
- package/ios/RNNotifee/NotifeeApiModule.h +25 -0
- package/ios/RNNotifee/NotifeeApiModule.m +371 -0
- package/ios/RNNotifee/NotifeeExtensionHelper.h +37 -0
- package/ios/RNNotifee/NotifeeExtensionHelper.m +37 -0
- package/ios/RNNotifee.xcodeproj/project.pbxproj +318 -0
- package/jest-mock.js +158 -0
- package/package.json +59 -0
- package/plugin/build/index.d.ts +3 -0
- package/plugin/build/index.js +12 -0
- package/plugin/build/index.js.map +1 -0
- package/plugin/build/withNotifeeProjectGradlePlugin.d.ts +5 -0
- package/plugin/build/withNotifeeProjectGradlePlugin.js +24 -0
- package/plugin/build/withNotifeeProjectGradlePlugin.js.map +1 -0
- package/plugin/src/index.ts +9 -0
- package/plugin/src/withNotifeeProjectGradlePlugin.ts +27 -0
- package/plugin/tsconfig.json +9 -0
- package/react-native.config.js +11 -0
- package/refresh-example.sh +71 -0
- package/src/NotifeeApiModule.ts +825 -0
- package/src/NotifeeJSEventEmitter.ts +11 -0
- package/src/NotifeeNativeError.ts +70 -0
- package/src/NotifeeNativeModule.ts +55 -0
- package/src/NotifeeNativeModule.web.ts +25 -0
- package/src/index.ts +33 -0
- package/src/types/Library.ts +28 -0
- package/src/types/Module.ts +625 -0
- package/src/types/Notification.ts +505 -0
- package/src/types/NotificationAndroid.ts +1443 -0
- package/src/types/NotificationIOS.ts +681 -0
- package/src/types/NotificationWeb.ts +5 -0
- package/src/types/PowerManagerInfo.ts +43 -0
- package/src/types/Trigger.ts +118 -0
- package/src/utils/id.ts +13 -0
- package/src/utils/index.ts +47 -0
- package/src/utils/validate.ts +92 -0
- package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfo.ts +45 -0
- package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.ts +33 -0
- package/src/validators/validate.ts +85 -0
- package/src/validators/validateAndroidAction.ts +54 -0
- package/src/validators/validateAndroidChannel.ts +188 -0
- package/src/validators/validateAndroidChannelGroup.ts +49 -0
- package/src/validators/validateAndroidFullScreenAction.ts +65 -0
- package/src/validators/validateAndroidInput.ts +67 -0
- package/src/validators/validateAndroidNotification.ts +704 -0
- package/src/validators/validateAndroidPressAction.ts +65 -0
- package/src/validators/validateAndroidStyle.ts +315 -0
- package/src/validators/validateIOSAttachment.ts +136 -0
- package/src/validators/validateIOSCategory.ts +150 -0
- package/src/validators/validateIOSCategoryAction.ts +65 -0
- package/src/validators/validateIOSInput.ts +38 -0
- package/src/validators/validateIOSNotification.ts +296 -0
- package/src/validators/validateIOSPermissions.ts +78 -0
- package/src/validators/validateNotification.ts +156 -0
- package/src/validators/validateTrigger.ts +134 -0
- package/src/version.ts +2 -0
- 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
|