@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,72 @@
|
|
|
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 <UIKit/UIKit.h>
|
|
19
|
+
#import "NotifeeCore+NSNotificationCenter.h"
|
|
20
|
+
#import "NotifeeCore+UNUserNotificationCenter.h"
|
|
21
|
+
|
|
22
|
+
@implementation NotifeeCoreNSNotificationCenter
|
|
23
|
+
|
|
24
|
+
+ (instancetype)instance {
|
|
25
|
+
static dispatch_once_t once;
|
|
26
|
+
__strong static NotifeeCoreNSNotificationCenter *sharedInstance;
|
|
27
|
+
dispatch_once(&once, ^{
|
|
28
|
+
sharedInstance = [[NotifeeCoreNSNotificationCenter alloc] init];
|
|
29
|
+
});
|
|
30
|
+
return sharedInstance;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (void)observe {
|
|
34
|
+
static dispatch_once_t once;
|
|
35
|
+
__weak NotifeeCoreNSNotificationCenter *weakSelf = self;
|
|
36
|
+
dispatch_once(&once, ^{
|
|
37
|
+
NotifeeCoreNSNotificationCenter *strongSelf = weakSelf;
|
|
38
|
+
// Application
|
|
39
|
+
// ObjC -> Initialize other delegates & observers
|
|
40
|
+
[[NSNotificationCenter defaultCenter]
|
|
41
|
+
addObserver:strongSelf
|
|
42
|
+
selector:@selector(application_onDidFinishLaunchingNotification:)
|
|
43
|
+
name:UIApplicationDidFinishLaunchingNotification
|
|
44
|
+
object:nil];
|
|
45
|
+
[[NSNotificationCenter defaultCenter]
|
|
46
|
+
addObserver:strongSelf
|
|
47
|
+
selector:@selector(messaging_didReceiveRemoteNotification:)
|
|
48
|
+
name:@"RNFBMessagingDidReceiveRemoteNotification"
|
|
49
|
+
object:nil];
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// start observing immediately on class load - specifically for
|
|
54
|
+
// UIApplicationDidFinishLaunchingNotification
|
|
55
|
+
+ (void)load {
|
|
56
|
+
[[self instance] observe];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#pragma mark -
|
|
60
|
+
#pragma mark Application Notifications
|
|
61
|
+
|
|
62
|
+
- (void)application_onDidFinishLaunchingNotification:(nonnull NSNotification *)notification {
|
|
63
|
+
// setup our delegates after app finishes launching
|
|
64
|
+
// these methods are idempotent so can safely be called multiple times
|
|
65
|
+
[[NotifeeCoreUNUserNotificationCenter instance] observe];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (void)messaging_didReceiveRemoteNotification:(nonnull NSNotification *)notification {
|
|
69
|
+
// update me with logic
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@end
|
|
@@ -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
|
+
|
|
20
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
21
|
+
@interface NotifeeCoreNSURLSession : NSObject
|
|
22
|
+
+ (NSString *)downloadItemAtURL:(NSURL *)url toFile:(NSString *)localPath error:(NSError **)error;
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,55 @@
|
|
|
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 "NotifeeCore+NSURLSession.h"
|
|
19
|
+
#import "NotifeeCoreDownloadDelegate.h"
|
|
20
|
+
|
|
21
|
+
@implementation NotifeeCoreNSURLSession
|
|
22
|
+
|
|
23
|
+
+ (NSString *)downloadItemAtURL:(NSURL *)url toFile:(NSString *)localPath error:(NSError **)error {
|
|
24
|
+
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
|
|
25
|
+
|
|
26
|
+
NotifeeCoreDownloadDelegate *delegate =
|
|
27
|
+
[[NotifeeCoreDownloadDelegate alloc] initWithFilePath:localPath];
|
|
28
|
+
|
|
29
|
+
// The session is created with the defaultSessionConfiguration
|
|
30
|
+
// default timeoutIntervalForRequest is 60 seconds.
|
|
31
|
+
NSURLSession *session =
|
|
32
|
+
[NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
|
|
33
|
+
delegate:delegate
|
|
34
|
+
delegateQueue:nil];
|
|
35
|
+
|
|
36
|
+
NSURLSessionDataTask *task = [session dataTaskWithRequest:request];
|
|
37
|
+
|
|
38
|
+
[task resume];
|
|
39
|
+
|
|
40
|
+
[session finishTasksAndInvalidate];
|
|
41
|
+
|
|
42
|
+
while (![delegate isDone]) {
|
|
43
|
+
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
NSError *delegateError = [delegate error];
|
|
47
|
+
if (delegateError != nil) {
|
|
48
|
+
if (error) *error = delegateError;
|
|
49
|
+
return nil;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return delegate.response.suggestedFilename;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@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 <Foundation/Foundation.h>
|
|
19
|
+
#import <UserNotifications/UserNotifications.h>
|
|
20
|
+
|
|
21
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
22
|
+
|
|
23
|
+
@interface NotifeeCoreUNUserNotificationCenter : NSObject <UNUserNotificationCenterDelegate>
|
|
24
|
+
|
|
25
|
+
@property(nonatomic, nullable, weak) id<UNUserNotificationCenterDelegate> originalDelegate;
|
|
26
|
+
|
|
27
|
+
@property(strong, nullable) NSDictionary *initialNotification;
|
|
28
|
+
|
|
29
|
+
+ (_Nonnull instancetype)instance;
|
|
30
|
+
|
|
31
|
+
- (void)observe;
|
|
32
|
+
|
|
33
|
+
- (nullable NSDictionary *)getInitialNotification;
|
|
34
|
+
|
|
35
|
+
@end
|
|
36
|
+
|
|
37
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,242 @@
|
|
|
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 "NotifeeCore+UNUserNotificationCenter.h"
|
|
19
|
+
|
|
20
|
+
#import "NotifeeCoreDelegateHolder.h"
|
|
21
|
+
#import "NotifeeCoreUtil.h"
|
|
22
|
+
|
|
23
|
+
@implementation NotifeeCoreUNUserNotificationCenter
|
|
24
|
+
struct {
|
|
25
|
+
unsigned int willPresentNotification : 1;
|
|
26
|
+
unsigned int didReceiveNotificationResponse : 1;
|
|
27
|
+
unsigned int openSettingsForNotification : 1;
|
|
28
|
+
} originalUNCDelegateRespondsTo;
|
|
29
|
+
|
|
30
|
+
+ (instancetype)instance {
|
|
31
|
+
static dispatch_once_t once;
|
|
32
|
+
__strong static NotifeeCoreUNUserNotificationCenter *sharedInstance;
|
|
33
|
+
dispatch_once(&once, ^{
|
|
34
|
+
sharedInstance = [[NotifeeCoreUNUserNotificationCenter alloc] init];
|
|
35
|
+
sharedInstance.initialNotification = nil;
|
|
36
|
+
});
|
|
37
|
+
return sharedInstance;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
- (void)observe {
|
|
41
|
+
static dispatch_once_t once;
|
|
42
|
+
__weak NotifeeCoreUNUserNotificationCenter *weakSelf = self;
|
|
43
|
+
dispatch_once(&once, ^{
|
|
44
|
+
NotifeeCoreUNUserNotificationCenter *strongSelf = weakSelf;
|
|
45
|
+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
46
|
+
if (center.delegate != nil) {
|
|
47
|
+
_originalDelegate = center.delegate;
|
|
48
|
+
originalUNCDelegateRespondsTo.openSettingsForNotification = (unsigned int)[_originalDelegate
|
|
49
|
+
respondsToSelector:@selector(userNotificationCenter:openSettingsForNotification:)];
|
|
50
|
+
originalUNCDelegateRespondsTo.willPresentNotification = (unsigned int)[_originalDelegate
|
|
51
|
+
respondsToSelector:@selector(userNotificationCenter:
|
|
52
|
+
willPresentNotification:withCompletionHandler:)];
|
|
53
|
+
originalUNCDelegateRespondsTo.didReceiveNotificationResponse =
|
|
54
|
+
(unsigned int)[_originalDelegate
|
|
55
|
+
respondsToSelector:@selector(userNotificationCenter:
|
|
56
|
+
didReceiveNotificationResponse:withCompletionHandler:)];
|
|
57
|
+
}
|
|
58
|
+
center.delegate = strongSelf;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (nullable NSDictionary *)getInitialNotification {
|
|
63
|
+
if (_initialNotification != nil) {
|
|
64
|
+
NSDictionary *initialNotificationCopy = [_initialNotification copy];
|
|
65
|
+
_initialNotification = nil;
|
|
66
|
+
return initialNotificationCopy;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return nil;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#pragma mark - UNUserNotificationCenter Delegate Methods
|
|
73
|
+
|
|
74
|
+
// The method will be called on the delegate only if the application is in the
|
|
75
|
+
// foreground. If the the handler is not called in a timely manner then the
|
|
76
|
+
// notification will not be presented. The application can choose to have the
|
|
77
|
+
// notification presented as a sound, badge, alert and/or in the notification
|
|
78
|
+
// list. This decision should be based on whether the information in the
|
|
79
|
+
// notification is otherwise visible to the user.
|
|
80
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
81
|
+
willPresentNotification:(UNNotification *)notification
|
|
82
|
+
withCompletionHandler:
|
|
83
|
+
(void (^)(UNNotificationPresentationOptions options))completionHandler {
|
|
84
|
+
NSDictionary *notifeeNotification =
|
|
85
|
+
notification.request.content.userInfo[kNotifeeUserInfoNotification];
|
|
86
|
+
|
|
87
|
+
// we only care about notifications created through notifee
|
|
88
|
+
if (notifeeNotification != nil) {
|
|
89
|
+
UNNotificationPresentationOptions presentationOptions = UNNotificationPresentationOptionNone;
|
|
90
|
+
NSDictionary *foregroundPresentationOptions =
|
|
91
|
+
notifeeNotification[@"ios"][@"foregroundPresentationOptions"];
|
|
92
|
+
|
|
93
|
+
BOOL alert = [foregroundPresentationOptions[@"alert"] boolValue];
|
|
94
|
+
BOOL badge = [foregroundPresentationOptions[@"badge"] boolValue];
|
|
95
|
+
BOOL sound = [foregroundPresentationOptions[@"sound"] boolValue];
|
|
96
|
+
BOOL banner = [foregroundPresentationOptions[@"banner"] boolValue];
|
|
97
|
+
BOOL list = [foregroundPresentationOptions[@"list"] boolValue];
|
|
98
|
+
|
|
99
|
+
if (badge) {
|
|
100
|
+
presentationOptions |= UNNotificationPresentationOptionBadge;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (sound) {
|
|
104
|
+
presentationOptions |= UNNotificationPresentationOptionSound;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// if list or banner is true, ignore alert property
|
|
108
|
+
if (banner || list) {
|
|
109
|
+
if (banner) {
|
|
110
|
+
if (@available(iOS 14, *)) {
|
|
111
|
+
presentationOptions |= UNNotificationPresentationOptionBanner;
|
|
112
|
+
} else {
|
|
113
|
+
// for iOS 13 we need to set alert
|
|
114
|
+
presentationOptions |= UNNotificationPresentationOptionAlert;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (list) {
|
|
119
|
+
if (@available(iOS 14, *)) {
|
|
120
|
+
presentationOptions |= UNNotificationPresentationOptionList;
|
|
121
|
+
} else {
|
|
122
|
+
// for iOS 13 we need to set alert
|
|
123
|
+
presentationOptions |= UNNotificationPresentationOptionAlert;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
} else if (alert) {
|
|
127
|
+
// TODO: remove alert once it has been fully removed from the notifee API
|
|
128
|
+
presentationOptions |= UNNotificationPresentationOptionAlert;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
NSDictionary *notifeeTrigger = notification.request.content.userInfo[kNotifeeUserInfoTrigger];
|
|
132
|
+
if (notifeeTrigger != nil) {
|
|
133
|
+
// post DELIVERED event
|
|
134
|
+
[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:@{
|
|
135
|
+
@"type" : @(NotifeeCoreEventTypeDelivered),
|
|
136
|
+
@"detail" : @{
|
|
137
|
+
@"notification" : notifeeNotification,
|
|
138
|
+
}
|
|
139
|
+
}];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
completionHandler(presentationOptions);
|
|
143
|
+
|
|
144
|
+
} else if (_originalDelegate != nil && originalUNCDelegateRespondsTo.willPresentNotification) {
|
|
145
|
+
[_originalDelegate userNotificationCenter:center
|
|
146
|
+
willPresentNotification:notification
|
|
147
|
+
withCompletionHandler:completionHandler];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// The method will be called when the user responded to the notification by
|
|
152
|
+
// opening the application, dismissing the notification or choosing a
|
|
153
|
+
// UNNotificationAction. The delegate must be set before the application returns
|
|
154
|
+
// from application:didFinishLaunchingWithOptions:.
|
|
155
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
156
|
+
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
157
|
+
withCompletionHandler:(void (^)(void))completionHandler {
|
|
158
|
+
NSDictionary *notifeeNotification =
|
|
159
|
+
response.notification.request.content.userInfo[kNotifeeUserInfoNotification];
|
|
160
|
+
|
|
161
|
+
// handle notification outside of notifee
|
|
162
|
+
if (notifeeNotification == nil) {
|
|
163
|
+
notifeeNotification =
|
|
164
|
+
[NotifeeCoreUtil parseUNNotificationRequest:response.notification.request];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (notifeeNotification != nil) {
|
|
168
|
+
if ([response.actionIdentifier isEqualToString:UNNotificationDismissActionIdentifier]) {
|
|
169
|
+
// post DISMISSED event, only triggers if notification has a categoryId
|
|
170
|
+
[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:@{
|
|
171
|
+
@"type" : @(NotifeeCoreEventTypeDismissed),
|
|
172
|
+
@"detail" : @{
|
|
173
|
+
@"notification" : notifeeNotification,
|
|
174
|
+
}
|
|
175
|
+
}];
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
NSNumber *eventType;
|
|
180
|
+
NSMutableDictionary *event = [NSMutableDictionary dictionary];
|
|
181
|
+
NSMutableDictionary *eventDetail = [NSMutableDictionary dictionary];
|
|
182
|
+
NSMutableDictionary *eventDetailPressAction = [NSMutableDictionary dictionary];
|
|
183
|
+
|
|
184
|
+
if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) {
|
|
185
|
+
eventType = @1; // PRESS
|
|
186
|
+
// event.detail.pressAction.id
|
|
187
|
+
eventDetailPressAction[@"id"] = @"default";
|
|
188
|
+
} else {
|
|
189
|
+
eventType = @2; // ACTION_PRESS
|
|
190
|
+
// event.detail.pressAction.id
|
|
191
|
+
eventDetailPressAction[@"id"] = response.actionIdentifier;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if ([response isKindOfClass:UNTextInputNotificationResponse.class]) {
|
|
195
|
+
// event.detail.input
|
|
196
|
+
eventDetail[@"input"] = [(UNTextInputNotificationResponse *)response userText];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// event.type
|
|
200
|
+
event[@"type"] = eventType;
|
|
201
|
+
|
|
202
|
+
// event.detail.notification
|
|
203
|
+
eventDetail[@"notification"] = notifeeNotification;
|
|
204
|
+
|
|
205
|
+
// event.detail.pressAction
|
|
206
|
+
eventDetail[@"pressAction"] = eventDetailPressAction;
|
|
207
|
+
|
|
208
|
+
// event.detail
|
|
209
|
+
event[@"detail"] = eventDetail;
|
|
210
|
+
|
|
211
|
+
// store notification for getInitialNotification
|
|
212
|
+
_initialNotification = [eventDetail copy];
|
|
213
|
+
|
|
214
|
+
// post PRESS/ACTION_PRESS event
|
|
215
|
+
[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:event];
|
|
216
|
+
|
|
217
|
+
// TODO figure out if this is needed or if we can just complete immediately
|
|
218
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(15 * NSEC_PER_SEC)),
|
|
219
|
+
dispatch_get_main_queue(), ^{
|
|
220
|
+
completionHandler();
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
} else if (_originalDelegate != nil &&
|
|
224
|
+
originalUNCDelegateRespondsTo.didReceiveNotificationResponse) {
|
|
225
|
+
[_originalDelegate userNotificationCenter:center
|
|
226
|
+
didReceiveNotificationResponse:response
|
|
227
|
+
withCompletionHandler:completionHandler];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
232
|
+
openSettingsForNotification:(nullable UNNotification *)notification {
|
|
233
|
+
if (_originalDelegate != nil && originalUNCDelegateRespondsTo.openSettingsForNotification) {
|
|
234
|
+
if (@available(iOS 12.0, macOS 10.14, macCatalyst 13.0, *)) {
|
|
235
|
+
[_originalDelegate userNotificationCenter:center openSettingsForNotification:notification];
|
|
236
|
+
} else {
|
|
237
|
+
// Fallback on earlier versions
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@end
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|
+
//! Project version number for NotifeeCore.
|
|
20
|
+
FOUNDATION_EXPORT double NotifeeCoreVersionNumber;
|
|
21
|
+
#import <UserNotifications/UserNotifications.h>
|
|
22
|
+
|
|
23
|
+
//! Project version string for NotifeeCore.
|
|
24
|
+
FOUNDATION_EXPORT const unsigned char NotifeeCoreVersionString[];
|
|
25
|
+
|
|
26
|
+
// Import all the public headers of your framework using statements like #import
|
|
27
|
+
// <NotifeeCore/PublicHeader.h> #import <NotifeeCore/Example.h> END public
|
|
28
|
+
// headers import
|
|
29
|
+
|
|
30
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
31
|
+
|
|
32
|
+
typedef void (^notifeeMethodVoidBlock)(NSError *_Nullable);
|
|
33
|
+
|
|
34
|
+
typedef void (^notifeeMethodNSDictionaryBlock)(NSError *_Nullable, NSDictionary *_Nullable);
|
|
35
|
+
|
|
36
|
+
typedef void (^notifeeMethodNSArrayBlock)(NSError *_Nullable, NSArray *_Nullable);
|
|
37
|
+
|
|
38
|
+
typedef void (^notifeeMethodBooleanBlock)(NSError *_Nullable, BOOL);
|
|
39
|
+
|
|
40
|
+
typedef void (^notifeeMethodNSIntegerBlock)(NSError *_Nullable, NSInteger);
|
|
41
|
+
|
|
42
|
+
typedef NS_ENUM(NSInteger, NotifeeCoreNotificationType) {
|
|
43
|
+
NotifeeCoreNotificationTypeAll = 0,
|
|
44
|
+
NotifeeCoreNotificationTypeDisplayed = 1,
|
|
45
|
+
NotifeeCoreNotificationTypeTrigger = 2
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
typedef NS_ENUM(NSInteger, NotifeeCoreEventType) {
|
|
49
|
+
NotifeeCoreEventTypeDismissed = 0,
|
|
50
|
+
NotifeeCoreEventTypeDelivered = 3,
|
|
51
|
+
NotifeeCoreEventTypeTriggerNotificationCreated = 7,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
@class NotifeeCore;
|
|
55
|
+
|
|
56
|
+
@protocol NotifeeCoreDelegate <NSObject>
|
|
57
|
+
@optional
|
|
58
|
+
- (void)didReceiveNotifeeCoreEvent:(NSDictionary *_Nonnull)event;
|
|
59
|
+
@end
|
|
60
|
+
|
|
61
|
+
@interface NotifeeCore : NSObject
|
|
62
|
+
|
|
63
|
+
+ (void)setCoreDelegate:(id<NotifeeCoreDelegate>)coreDelegate;
|
|
64
|
+
|
|
65
|
+
+ (void)cancelNotification:(NSString *)notificationId
|
|
66
|
+
withNotificationType:(NSInteger)notificationType
|
|
67
|
+
withBlock:(notifeeMethodVoidBlock)block;
|
|
68
|
+
|
|
69
|
+
+ (void)cancelAllNotifications:(NSInteger)notificationType withBlock:(notifeeMethodVoidBlock)block;
|
|
70
|
+
|
|
71
|
+
+ (void)cancelAllNotificationsWithIds:(NSInteger)notificationType
|
|
72
|
+
withIds:(NSArray<NSString *> *)ids
|
|
73
|
+
withBlock:(notifeeMethodVoidBlock)block;
|
|
74
|
+
|
|
75
|
+
+ (void)displayNotification:(NSDictionary *)notification withBlock:(notifeeMethodVoidBlock)block;
|
|
76
|
+
|
|
77
|
+
+ (void)createTriggerNotification:(NSDictionary *)notification
|
|
78
|
+
withTrigger:(NSDictionary *)trigger
|
|
79
|
+
withBlock:(notifeeMethodVoidBlock)block;
|
|
80
|
+
|
|
81
|
+
+ (void)getTriggerNotificationIds:(notifeeMethodNSArrayBlock)block;
|
|
82
|
+
|
|
83
|
+
+ (void)getDisplayedNotifications:(notifeeMethodNSArrayBlock)block;
|
|
84
|
+
|
|
85
|
+
+ (void)getTriggerNotifications:(notifeeMethodNSArrayBlock)block;
|
|
86
|
+
|
|
87
|
+
+ (void)requestPermission:(NSDictionary *)permissions
|
|
88
|
+
withBlock:(notifeeMethodNSDictionaryBlock)block;
|
|
89
|
+
|
|
90
|
+
+ (void)getNotificationCategories:(notifeeMethodNSArrayBlock)block;
|
|
91
|
+
|
|
92
|
+
+ (void)setNotificationCategories:(NSArray<NSDictionary *> *)categories
|
|
93
|
+
withBlock:(notifeeMethodVoidBlock)block;
|
|
94
|
+
|
|
95
|
+
+ (void)getNotificationSettings:(notifeeMethodNSDictionaryBlock)block;
|
|
96
|
+
|
|
97
|
+
+ (void)getInitialNotification:(notifeeMethodNSDictionaryBlock)block;
|
|
98
|
+
|
|
99
|
+
+ (void)setBadgeCount:(NSInteger)count withBlock:(notifeeMethodVoidBlock)block;
|
|
100
|
+
|
|
101
|
+
+ (void)getBadgeCount:(notifeeMethodNSIntegerBlock)block;
|
|
102
|
+
|
|
103
|
+
+ (void)incrementBadgeCount:(NSInteger)incrementBy withBlock:(notifeeMethodVoidBlock)block;
|
|
104
|
+
|
|
105
|
+
+ (void)decrementBadgeCount:(NSInteger)decrementBy withBlock:(notifeeMethodVoidBlock)block;
|
|
106
|
+
|
|
107
|
+
+ (nullable instancetype)notifeeUIApplication;
|
|
108
|
+
|
|
109
|
+
+ (UNMutableNotificationContent *)buildNotificationContent:(NSDictionary *)notification
|
|
110
|
+
withTrigger:(NSDictionary *_Nullable)trigger;
|
|
111
|
+
|
|
112
|
+
+ (void)populateNotificationContent:(UNNotificationRequest *_Nullable)request
|
|
113
|
+
withContent:(UNMutableNotificationContent *)content
|
|
114
|
+
withContentHandler:(void (^)(UNNotificationContent *_Nonnull))contentHandler;
|
|
115
|
+
|
|
116
|
+
@end
|
|
117
|
+
|
|
118
|
+
NS_ASSUME_NONNULL_END
|