@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,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The interface that represents the information returned from `getPowerManagerInfo()`.
|
|
7
|
+
*
|
|
8
|
+
* View the [Background Restrictions](/react-native/docs/android/background-restrictions) documentation to learn more.
|
|
9
|
+
*
|
|
10
|
+
* @platform android
|
|
11
|
+
*/
|
|
12
|
+
export interface PowerManagerInfo {
|
|
13
|
+
/**
|
|
14
|
+
* The device manufacturer.
|
|
15
|
+
*
|
|
16
|
+
* For example, Samsung.
|
|
17
|
+
*/
|
|
18
|
+
manufacturer?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The device model.
|
|
22
|
+
*
|
|
23
|
+
* For example, Galaxy S8
|
|
24
|
+
*/
|
|
25
|
+
model?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The Android version
|
|
29
|
+
*
|
|
30
|
+
* For example, Android 10
|
|
31
|
+
*/
|
|
32
|
+
version?: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The activity that the user will be navigated to if `openPowerManagerSettings()` is called.
|
|
36
|
+
*
|
|
37
|
+
* Use this as an indicator of what steps the user may have to perform,
|
|
38
|
+
* in-order to prevent your app from being killed.
|
|
39
|
+
*
|
|
40
|
+
* If no activity can be found, value will be null.
|
|
41
|
+
*/
|
|
42
|
+
activity?: string | null;
|
|
43
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for building a trigger with a timestamp.
|
|
3
|
+
*
|
|
4
|
+
* View the [Triggers](/react-native/docs/triggers) documentation to learn more.
|
|
5
|
+
*/
|
|
6
|
+
export interface TimestampTrigger {
|
|
7
|
+
/**
|
|
8
|
+
* Constant enum value used to identify the trigger type.
|
|
9
|
+
*/
|
|
10
|
+
type: TriggerType.TIMESTAMP;
|
|
11
|
+
/**
|
|
12
|
+
* The timestamp when the notification should first be shown, in milliseconds since 1970.
|
|
13
|
+
*/
|
|
14
|
+
timestamp: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The frequency at which the trigger repeats.
|
|
18
|
+
* If unset, the notification will only be displayed once.
|
|
19
|
+
*
|
|
20
|
+
* For example:
|
|
21
|
+
* if set to `RepeatFrequency.HOURLY`, the notification will repeat every hour from the timestamp specified.
|
|
22
|
+
* if set to `RepeatFrequency.DAILY`, the notification will repeat every day from the timestamp specified.
|
|
23
|
+
* if set to `RepeatFrequency.WEEKLY`, the notification will repeat every week from the timestamp specified.
|
|
24
|
+
*/
|
|
25
|
+
repeatFrequency?: RepeatFrequency;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Choose to schedule your trigger notification with Android's AlarmManager API.
|
|
29
|
+
*
|
|
30
|
+
* By default, trigger notifications are created with Android's WorkManager API.
|
|
31
|
+
*
|
|
32
|
+
* @platform android
|
|
33
|
+
*/
|
|
34
|
+
alarmManager?: boolean | TimestampTriggerAlarmManager | undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Interface to specify additional options for the AlarmManager which can be used with `TimestampTrigger.alarmManager`.
|
|
39
|
+
*
|
|
40
|
+
* View the [Triggers](/react-native/docs/triggers) documentation to learn more.
|
|
41
|
+
*
|
|
42
|
+
* @platform android
|
|
43
|
+
*/
|
|
44
|
+
export interface TimestampTriggerAlarmManager {
|
|
45
|
+
/**
|
|
46
|
+
* Sets whether your trigger notification should be displayed even when the system is in low-power idle modes.
|
|
47
|
+
*
|
|
48
|
+
* Defaults to `false`.
|
|
49
|
+
*/
|
|
50
|
+
allowWhileIdle?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* An interface representing the different frequencies which can be used with `TimestampTrigger.repeatFrequency`.
|
|
55
|
+
*
|
|
56
|
+
* View the [Triggers](/react-native/docs/triggers) documentation to learn more.
|
|
57
|
+
*/
|
|
58
|
+
export enum RepeatFrequency {
|
|
59
|
+
NONE = -1,
|
|
60
|
+
HOURLY = 0,
|
|
61
|
+
DAILY = 1,
|
|
62
|
+
WEEKLY = 2,
|
|
63
|
+
MONTHLY = 3,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Interface for building a trigger that repeats at a specified interval.
|
|
68
|
+
*
|
|
69
|
+
* View the [Triggers](/react-native/docs/triggers) documentation to learn more.
|
|
70
|
+
*/
|
|
71
|
+
export interface IntervalTrigger {
|
|
72
|
+
/**
|
|
73
|
+
* Constant enum value used to identify the trigger type.
|
|
74
|
+
*/
|
|
75
|
+
type: TriggerType.INTERVAL;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* How frequently the notification should be repeated.
|
|
79
|
+
*
|
|
80
|
+
* For example, if set to 30, the notification will be displayed every 30 minutes.
|
|
81
|
+
*
|
|
82
|
+
* Must be set to a minimum of 15 minutes.
|
|
83
|
+
*/
|
|
84
|
+
interval: number;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The unit of time that the `interval` is measured in.
|
|
88
|
+
*
|
|
89
|
+
* For example, if set to `TimeUnit.DAYS` and repeat interval is set to 3, the notification will repeat every 3 days.
|
|
90
|
+
*
|
|
91
|
+
* Defaults to `TimeUnit.SECONDS`
|
|
92
|
+
*/
|
|
93
|
+
timeUnit?: TimeUnit | TimeUnit.SECONDS;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* An interface representing the different units of time which can be used with `IntervalTrigger.timeUnit`.
|
|
98
|
+
*
|
|
99
|
+
* View the [Triggers](/react-native/docs/triggers) documentation to learn more.
|
|
100
|
+
*/
|
|
101
|
+
export enum TimeUnit {
|
|
102
|
+
SECONDS = 'SECONDS',
|
|
103
|
+
MINUTES = 'MINUTES',
|
|
104
|
+
HOURS = 'HOURS',
|
|
105
|
+
DAYS = 'DAYS',
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Available Trigger Types.
|
|
110
|
+
*
|
|
111
|
+
* View the [Triggers](/react-native/docs/triggers) documentation to learn more with example usage.
|
|
112
|
+
*/
|
|
113
|
+
export enum TriggerType {
|
|
114
|
+
TIMESTAMP = 0,
|
|
115
|
+
INTERVAL = 1,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export declare type Trigger = TimestampTrigger | IntervalTrigger;
|
package/src/utils/id.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const CHARACTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
6
|
+
|
|
7
|
+
export function generateId(): string {
|
|
8
|
+
let newId = '';
|
|
9
|
+
for (let i = 0; i < 20; i++) {
|
|
10
|
+
newId += CHARACTERS.charAt(Math.floor(Math.random() * CHARACTERS.length));
|
|
11
|
+
}
|
|
12
|
+
return newId;
|
|
13
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
|
+
|
|
7
|
+
export * from './id';
|
|
8
|
+
export * from './validate';
|
|
9
|
+
|
|
10
|
+
/* eslint-disable-next-line @typescript-eslint/ban-types */
|
|
11
|
+
export function isError(value: object): boolean {
|
|
12
|
+
if (Object.prototype.toString.call(value) === '[object Error]') {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return value instanceof Error;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function objectHasProperty<T>(
|
|
20
|
+
target: T,
|
|
21
|
+
property: string | number | symbol,
|
|
22
|
+
): property is keyof T {
|
|
23
|
+
return Object.hasOwnProperty.call(target, property);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const isIOS = Platform.OS === 'ios';
|
|
27
|
+
|
|
28
|
+
export const isAndroid = Platform.OS === 'android';
|
|
29
|
+
|
|
30
|
+
export const isWeb = Platform.OS === 'web';
|
|
31
|
+
|
|
32
|
+
export function noop(): void {
|
|
33
|
+
// noop-🐈
|
|
34
|
+
}
|
|
35
|
+
export const kReactNativeNotifeeForegroundServiceHeadlessTask =
|
|
36
|
+
'app.notifee.foreground-service-headless-task';
|
|
37
|
+
|
|
38
|
+
export const kReactNativeNotifeeNotificationEvent = 'app.notifee.notification-event';
|
|
39
|
+
|
|
40
|
+
export const kReactNativeNotifeeNotificationBackgroundEvent =
|
|
41
|
+
'app.notifee.notification-event-background';
|
|
42
|
+
|
|
43
|
+
export enum NotificationType {
|
|
44
|
+
ALL = 0,
|
|
45
|
+
DISPLAYED = 1,
|
|
46
|
+
TRIGGER = 2,
|
|
47
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
5
|
+
*/
|
|
6
|
+
export function isNull(value: any): value is null {
|
|
7
|
+
return value === null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function isObject(value: any): value is object {
|
|
11
|
+
return value ? typeof value === 'object' && !Array.isArray(value) && !isNull(value) : false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isFunction(value: any): value is Function {
|
|
15
|
+
return value ? typeof value === 'function' : false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function isString(value: any): value is string {
|
|
19
|
+
return typeof value === 'string';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function isNumber(value: any): value is number {
|
|
23
|
+
return typeof value === 'number';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function isBoolean(value: any): value is boolean {
|
|
27
|
+
return typeof value === 'boolean';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function isArray(value: any): value is Array<any> {
|
|
31
|
+
return Array.isArray(value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function isArrayOfStrings(value: any): value is Array<string> {
|
|
35
|
+
if (!isArray(value)) return false;
|
|
36
|
+
for (let i = 0; i < value.length; i++) {
|
|
37
|
+
if (!isString(value[i])) return false;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function isUndefined(value: any): value is undefined {
|
|
43
|
+
return value === undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function objectKeyValuesAreStrings(value: object): value is { [key: string]: string } {
|
|
47
|
+
if (!isObject(value)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const entries = Object.entries(value);
|
|
52
|
+
|
|
53
|
+
for (let i = 0; i < entries.length; i++) {
|
|
54
|
+
const [key, entryValue] = entries[i];
|
|
55
|
+
if (!isString(key) || !isString(entryValue)) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* /^[a-zA-Z0-9_]+$/
|
|
65
|
+
*
|
|
66
|
+
* @param value
|
|
67
|
+
* @returns {boolean}
|
|
68
|
+
*/
|
|
69
|
+
const AlphaNumericUnderscore = /^[a-zA-Z0-9_]+$/;
|
|
70
|
+
|
|
71
|
+
export function isAlphaNumericUnderscore(value: string): boolean {
|
|
72
|
+
return AlphaNumericUnderscore.test(value);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* URL test
|
|
77
|
+
* @param url
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
const IS_VALID_URL_REGEX = /^(http|https):\/\/[^ "]+$/;
|
|
81
|
+
|
|
82
|
+
export function isValidUrl(url: string): boolean {
|
|
83
|
+
return IS_VALID_URL_REGEX.test(url);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function isValidEnum(value: any, enumType: Record<string, any>): boolean {
|
|
87
|
+
if (!Object.values(enumType).includes(value)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IOSCommunicationInfo } from '../../types/NotificationIOS';
|
|
2
|
+
import { isObject, isString } from '../../utils';
|
|
3
|
+
import validateIOSCommunicationInfoPerson from './validateIOSCommunicationInfoPerson';
|
|
4
|
+
|
|
5
|
+
export default function validateIOSCommunicationInfo(
|
|
6
|
+
communicationInfo: IOSCommunicationInfo,
|
|
7
|
+
): IOSCommunicationInfo {
|
|
8
|
+
if (!isObject(communicationInfo)) {
|
|
9
|
+
throw new Error('expected an object.');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (
|
|
13
|
+
!isString(communicationInfo.conversationId) ||
|
|
14
|
+
communicationInfo.conversationId.length === 0
|
|
15
|
+
) {
|
|
16
|
+
throw new Error("'conversationId' expected a valid string value.");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!communicationInfo.sender || !isObject(communicationInfo.sender)) {
|
|
20
|
+
throw new Error("'sender' expected a valid object value.");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let sender;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
sender = validateIOSCommunicationInfoPerson(communicationInfo.sender);
|
|
27
|
+
} catch (e: any) {
|
|
28
|
+
throw new Error(`'sender' ${e.message}.`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const out: IOSCommunicationInfo = {
|
|
32
|
+
conversationId: communicationInfo.conversationId,
|
|
33
|
+
sender,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (communicationInfo.body) {
|
|
37
|
+
if (!isString(communicationInfo.body)) {
|
|
38
|
+
throw new Error("'body' expected a valid string value.");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
out.body = communicationInfo.body;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IOSCommunicationInfoPerson } from '../../types/NotificationIOS';
|
|
2
|
+
import { objectHasProperty, isObject, isString, isUndefined } from '../../utils';
|
|
3
|
+
|
|
4
|
+
export default function validateIOSCommunicationInfoPerson(
|
|
5
|
+
person: IOSCommunicationInfoPerson,
|
|
6
|
+
): IOSCommunicationInfoPerson {
|
|
7
|
+
if (!isObject(person)) {
|
|
8
|
+
throw new Error("'person' expected an object.");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (!isString(person.id) || person.id.length === 0) {
|
|
12
|
+
throw new Error('"person.id" expected a valid string value.');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!isString(person.displayName) || person.displayName.length === 0) {
|
|
16
|
+
throw new Error('"person.displayName" expected a valid string value.');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const out: IOSCommunicationInfoPerson = {
|
|
20
|
+
id: person.id,
|
|
21
|
+
displayName: person.displayName,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
if (objectHasProperty(person, 'avatar') && !isUndefined(person.avatar)) {
|
|
25
|
+
if (!isString(person.avatar)) {
|
|
26
|
+
throw new Error('"person.avatar" expected a valid object value.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
out.avatar = person.avatar;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AndroidColor } from '../types/NotificationAndroid';
|
|
6
|
+
import { isNumber } from '../utils';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validates any hexadecimal (optional transparency)
|
|
10
|
+
* @param color
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
export function isValidColor(color: string): boolean {
|
|
14
|
+
if (Object.values(AndroidColor).includes(color as AndroidColor)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!color.startsWith('#')) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// exclude #
|
|
23
|
+
const length = color.length - 1;
|
|
24
|
+
return length === 6 || length === 8;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Checks the timestamp is at some point in the future.
|
|
29
|
+
* @param timestamp
|
|
30
|
+
* @returns {boolean}
|
|
31
|
+
*/
|
|
32
|
+
export function isValidTimestamp(timestamp: number): boolean {
|
|
33
|
+
return timestamp > 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Ensures all values in the pattern are valid
|
|
38
|
+
* @param pattern {array}
|
|
39
|
+
*/
|
|
40
|
+
export function isValidVibratePattern(pattern: number[]): boolean {
|
|
41
|
+
if (pattern.length % 2 !== 0) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
45
|
+
const ms = pattern[i];
|
|
46
|
+
if (!isNumber(ms)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (ms <= 0) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Ensures a given light pattern is valid
|
|
58
|
+
* @param pattern {array}
|
|
59
|
+
*/
|
|
60
|
+
type LightPattern = [string, number, number];
|
|
61
|
+
type ValidLightPattern = [boolean] | [boolean, 'color' | 'onMs' | 'offMs'];
|
|
62
|
+
|
|
63
|
+
export function isValidLightPattern(pattern: LightPattern): ValidLightPattern {
|
|
64
|
+
const [color, onMs, offMs] = pattern;
|
|
65
|
+
|
|
66
|
+
if (!isValidColor(color)) {
|
|
67
|
+
return [false, 'color'];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!isNumber(onMs)) {
|
|
71
|
+
return [false, 'onMs'];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!isNumber(offMs)) {
|
|
75
|
+
return [false, 'offMs'];
|
|
76
|
+
}
|
|
77
|
+
if (onMs < 1) {
|
|
78
|
+
return [false, 'onMs'];
|
|
79
|
+
}
|
|
80
|
+
if (offMs < 1) {
|
|
81
|
+
return [false, 'offMs'];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return [true];
|
|
85
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { objectHasProperty, isObject, isString, isUndefined } from '../utils';
|
|
6
|
+
|
|
7
|
+
import { AndroidAction } from '../types/NotificationAndroid';
|
|
8
|
+
import validateAndroidPressAction from './validateAndroidPressAction';
|
|
9
|
+
import validateAndroidInput from './validateAndroidInput';
|
|
10
|
+
|
|
11
|
+
export default function validateAndroidAction(action: AndroidAction): AndroidAction {
|
|
12
|
+
if (!isObject(action)) {
|
|
13
|
+
throw new Error("'action' expected an object value.");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!isString(action.title) || !action.title) {
|
|
17
|
+
throw new Error("'action.title' expected a string value.");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let pressAction;
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
pressAction = validateAndroidPressAction(action.pressAction);
|
|
24
|
+
} catch (e: any) {
|
|
25
|
+
throw new Error(`'action' ${e.message}.`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const out: AndroidAction = {
|
|
29
|
+
title: action.title,
|
|
30
|
+
pressAction,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
if (objectHasProperty(action, 'icon') && !isUndefined(action.icon)) {
|
|
34
|
+
if (!isString(action.icon) || !action.icon) {
|
|
35
|
+
throw new Error("'action.icon' expected a string value.");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
out.icon = action.icon;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (objectHasProperty(action, 'input') && !isUndefined(action.input)) {
|
|
42
|
+
if (action.input === true) {
|
|
43
|
+
out.input = validateAndroidInput();
|
|
44
|
+
} else {
|
|
45
|
+
try {
|
|
46
|
+
out.input = validateAndroidInput(action.input);
|
|
47
|
+
} catch (e: any) {
|
|
48
|
+
throw new Error(`'action.input' ${e.message}.`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return out;
|
|
54
|
+
}
|