@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,349 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
package io.invertase.notifee;
|
|
6
|
+
|
|
7
|
+
import android.Manifest;
|
|
8
|
+
import android.os.Build;
|
|
9
|
+
import android.os.Bundle;
|
|
10
|
+
import androidx.annotation.NonNull;
|
|
11
|
+
import app.notifee.core.Logger;
|
|
12
|
+
import app.notifee.core.Notifee;
|
|
13
|
+
import com.facebook.react.bridge.Arguments;
|
|
14
|
+
import com.facebook.react.bridge.Promise;
|
|
15
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
16
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
17
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
18
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
19
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
20
|
+
import com.facebook.react.modules.core.PermissionAwareActivity;
|
|
21
|
+
import com.facebook.react.modules.core.PermissionListener;
|
|
22
|
+
import java.util.ArrayList;
|
|
23
|
+
import java.util.HashMap;
|
|
24
|
+
import java.util.Map;
|
|
25
|
+
|
|
26
|
+
public class NotifeeApiModule extends ReactContextBaseJavaModule implements PermissionListener {
|
|
27
|
+
private static final int NOTIFICATION_TYPE_DISPLAYED = 1;
|
|
28
|
+
private static final int NOTIFICATION_TYPE_TRIGGER = 2;
|
|
29
|
+
private static final int NOTIFICATION_TYPE_ALL = 0;
|
|
30
|
+
|
|
31
|
+
public NotifeeApiModule(@NonNull ReactApplicationContext reactContext) {
|
|
32
|
+
super(reactContext);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public static String getMainComponent(@NonNull String defaultComponent) {
|
|
36
|
+
return Notifee.getInstance().getMainComponent(defaultComponent);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Override
|
|
40
|
+
public void onCatalystInstanceDestroy() {
|
|
41
|
+
NotifeeReactUtils.clearRunningHeadlessTasks();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@ReactMethod
|
|
45
|
+
public void cancelAllNotifications(Promise promise) {
|
|
46
|
+
Notifee.getInstance()
|
|
47
|
+
.cancelAllNotifications(
|
|
48
|
+
NOTIFICATION_TYPE_ALL, (e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@ReactMethod
|
|
52
|
+
public void cancelDisplayedNotifications(Promise promise) {
|
|
53
|
+
Notifee.getInstance()
|
|
54
|
+
.cancelAllNotifications(
|
|
55
|
+
NOTIFICATION_TYPE_DISPLAYED,
|
|
56
|
+
(e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ReactMethod
|
|
60
|
+
public void cancelTriggerNotifications(Promise promise) {
|
|
61
|
+
Notifee.getInstance()
|
|
62
|
+
.cancelAllNotifications(
|
|
63
|
+
NOTIFICATION_TYPE_TRIGGER, (e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@ReactMethod
|
|
67
|
+
public void cancelAllNotificationsWithIds(
|
|
68
|
+
ReadableArray idsArray, int notificationType, String tag, Promise promise) {
|
|
69
|
+
ArrayList<String> ids = new ArrayList<>(idsArray.size());
|
|
70
|
+
for (int i = 0; i < idsArray.size(); i++) {
|
|
71
|
+
ids.add(idsArray.getString(i));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Notifee.getInstance()
|
|
75
|
+
.cancelAllNotificationsWithIds(
|
|
76
|
+
notificationType,
|
|
77
|
+
ids,
|
|
78
|
+
tag,
|
|
79
|
+
(e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@ReactMethod
|
|
83
|
+
public void getDisplayedNotifications(Promise promise) {
|
|
84
|
+
Notifee.getInstance()
|
|
85
|
+
.getDisplayedNotifications(
|
|
86
|
+
(e, aBundleList) -> NotifeeReactUtils.promiseResolver(promise, e, aBundleList));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@ReactMethod
|
|
90
|
+
public void getTriggerNotifications(Promise promise) {
|
|
91
|
+
Notifee.getInstance()
|
|
92
|
+
.getTriggerNotifications(
|
|
93
|
+
(e, aBundleList) -> NotifeeReactUtils.promiseResolver(promise, e, aBundleList));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@ReactMethod
|
|
97
|
+
public void getTriggerNotificationIds(Promise promise) {
|
|
98
|
+
Notifee.getInstance()
|
|
99
|
+
.getTriggerNotificationIds(
|
|
100
|
+
(e, aStringList) ->
|
|
101
|
+
NotifeeReactUtils.promiseStringListResolver(promise, e, aStringList));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@ReactMethod
|
|
105
|
+
public void createChannel(ReadableMap channelMap, Promise promise) {
|
|
106
|
+
Notifee.getInstance()
|
|
107
|
+
.createChannel(
|
|
108
|
+
Arguments.toBundle(channelMap),
|
|
109
|
+
(e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@ReactMethod
|
|
113
|
+
public void createChannels(ReadableArray channelsArray, Promise promise) {
|
|
114
|
+
ArrayList<Bundle> channels = new ArrayList<>(channelsArray.size());
|
|
115
|
+
for (int i = 0; i < channelsArray.size(); i++) {
|
|
116
|
+
channels.add(Arguments.toBundle(channelsArray.getMap(i)));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
Notifee.getInstance()
|
|
120
|
+
.createChannels(channels, (e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@ReactMethod
|
|
124
|
+
public void createChannelGroup(ReadableMap channelGroupMap, Promise promise) {
|
|
125
|
+
Notifee.getInstance()
|
|
126
|
+
.createChannelGroup(
|
|
127
|
+
Arguments.toBundle(channelGroupMap),
|
|
128
|
+
(e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@ReactMethod
|
|
132
|
+
public void createChannelGroups(ReadableArray channelGroupsArray, Promise promise) {
|
|
133
|
+
ArrayList<Bundle> channelGroups = new ArrayList<>(channelGroupsArray.size());
|
|
134
|
+
|
|
135
|
+
for (int i = 0; i < channelGroupsArray.size(); i++) {
|
|
136
|
+
channelGroups.add(Arguments.toBundle(channelGroupsArray.getMap(i)));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
Notifee.getInstance()
|
|
140
|
+
.createChannelGroups(
|
|
141
|
+
channelGroups, (e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@ReactMethod
|
|
145
|
+
public void deleteChannel(String channelId, Promise promise) {
|
|
146
|
+
Notifee.getInstance()
|
|
147
|
+
.deleteChannel(channelId, (e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@ReactMethod
|
|
151
|
+
public void deleteChannelGroup(String channelId, Promise promise) {
|
|
152
|
+
Notifee.getInstance()
|
|
153
|
+
.deleteChannelGroup(channelId, (e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@ReactMethod
|
|
157
|
+
public void displayNotification(ReadableMap notificationMap, Promise promise) {
|
|
158
|
+
Notifee.getInstance()
|
|
159
|
+
.displayNotification(
|
|
160
|
+
Arguments.toBundle(notificationMap),
|
|
161
|
+
(e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@ReactMethod
|
|
165
|
+
public void openAlarmPermissionSettings(Promise promise) {
|
|
166
|
+
Notifee.getInstance()
|
|
167
|
+
.openAlarmPermissionSettings(
|
|
168
|
+
getCurrentActivity(), (e, avoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@ReactMethod
|
|
172
|
+
public void createTriggerNotification(
|
|
173
|
+
ReadableMap notificationMap, ReadableMap triggerMap, Promise promise) {
|
|
174
|
+
Notifee.getInstance()
|
|
175
|
+
.createTriggerNotification(
|
|
176
|
+
Arguments.toBundle(notificationMap),
|
|
177
|
+
Arguments.toBundle(triggerMap),
|
|
178
|
+
(e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@ReactMethod
|
|
182
|
+
public void getChannels(Promise promise) {
|
|
183
|
+
Notifee.getInstance()
|
|
184
|
+
.getChannels(
|
|
185
|
+
(e, aBundleList) -> NotifeeReactUtils.promiseResolver(promise, e, aBundleList));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@ReactMethod
|
|
189
|
+
public void getChannel(String channelId, Promise promise) {
|
|
190
|
+
Notifee.getInstance()
|
|
191
|
+
.getChannel(
|
|
192
|
+
channelId, (e, aBundle) -> NotifeeReactUtils.promiseResolver(promise, e, aBundle));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@ReactMethod
|
|
196
|
+
public void getChannelGroups(Promise promise) {
|
|
197
|
+
Notifee.getInstance()
|
|
198
|
+
.getChannelGroups(
|
|
199
|
+
(e, aBundleList) -> NotifeeReactUtils.promiseResolver(promise, e, aBundleList));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@ReactMethod
|
|
203
|
+
public void getChannelGroup(String channelGroupId, Promise promise) {
|
|
204
|
+
Notifee.getInstance()
|
|
205
|
+
.getChannel(
|
|
206
|
+
channelGroupId, (e, aBundle) -> NotifeeReactUtils.promiseResolver(promise, e, aBundle));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@ReactMethod
|
|
210
|
+
public void isChannelCreated(String channelId, Promise promise) {
|
|
211
|
+
Notifee.getInstance()
|
|
212
|
+
.isChannelCreated(
|
|
213
|
+
channelId, (e, aBool) -> NotifeeReactUtils.promiseBooleanResolver(promise, e, aBool));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@ReactMethod
|
|
217
|
+
public void isChannelBlocked(String channelId, Promise promise) {
|
|
218
|
+
Notifee.getInstance()
|
|
219
|
+
.isChannelBlocked(
|
|
220
|
+
channelId, (e, aBool) -> NotifeeReactUtils.promiseBooleanResolver(promise, e, aBool));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
@ReactMethod
|
|
224
|
+
public void getInitialNotification(Promise promise) {
|
|
225
|
+
Notifee.getInstance()
|
|
226
|
+
.getInitialNotification(
|
|
227
|
+
getCurrentActivity(),
|
|
228
|
+
(e, aBundle) -> NotifeeReactUtils.promiseResolver(promise, e, aBundle));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
@ReactMethod
|
|
232
|
+
public void getNotificationSettings(Promise promise) {
|
|
233
|
+
Notifee.getInstance()
|
|
234
|
+
.getNotificationSettings(
|
|
235
|
+
(e, aBundle) -> NotifeeReactUtils.promiseResolver(promise, e, aBundle));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
@ReactMethod
|
|
239
|
+
public void requestPermission(Promise promise) {
|
|
240
|
+
// For Android 12 and below, we return the notification settings
|
|
241
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
|
242
|
+
Notifee.getInstance()
|
|
243
|
+
.getNotificationSettings(
|
|
244
|
+
(e, aBundle) -> NotifeeReactUtils.promiseResolver(promise, e, aBundle));
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// We have to handle this logic outside of our core module due to a react-native limitation
|
|
249
|
+
// with obtaining the correct actvity
|
|
250
|
+
PermissionAwareActivity activity = (PermissionAwareActivity) getCurrentActivity();
|
|
251
|
+
if (activity == null) {
|
|
252
|
+
Logger.d(
|
|
253
|
+
"requestPermission",
|
|
254
|
+
"Unable to get permissionAwareActivity for " + Build.VERSION.SDK_INT);
|
|
255
|
+
|
|
256
|
+
Notifee.getInstance()
|
|
257
|
+
.getNotificationSettings(
|
|
258
|
+
(e, aBundle) -> NotifeeReactUtils.promiseResolver(promise, e, aBundle));
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Setting the request permission callback before attempting to call requestPermissions
|
|
263
|
+
Notifee.getInstance()
|
|
264
|
+
.setRequestPermissionCallback(
|
|
265
|
+
(e, aBundle) -> NotifeeReactUtils.promiseResolver(promise, e, aBundle));
|
|
266
|
+
|
|
267
|
+
activity.requestPermissions(
|
|
268
|
+
new String[] {Manifest.permission.POST_NOTIFICATIONS},
|
|
269
|
+
Notifee.REQUEST_CODE_NOTIFICATION_PERMISSION,
|
|
270
|
+
this);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
@ReactMethod
|
|
274
|
+
public void openNotificationSettings(String channelId, Promise promise) {
|
|
275
|
+
Notifee.getInstance()
|
|
276
|
+
.openNotificationSettings(
|
|
277
|
+
channelId,
|
|
278
|
+
getCurrentActivity(),
|
|
279
|
+
(e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@ReactMethod
|
|
283
|
+
public void openBatteryOptimizationSettings(Promise promise) {
|
|
284
|
+
Notifee.getInstance()
|
|
285
|
+
.openBatteryOptimizationSettings(
|
|
286
|
+
getCurrentActivity(), (e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
@ReactMethod
|
|
290
|
+
public void isBatteryOptimizationEnabled(Promise promise) {
|
|
291
|
+
Notifee.getInstance()
|
|
292
|
+
.isBatteryOptimizationEnabled(
|
|
293
|
+
(e, aBool) -> NotifeeReactUtils.promiseBooleanResolver(promise, e, aBool));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
@ReactMethod
|
|
297
|
+
public void getPowerManagerInfo(Promise promise) {
|
|
298
|
+
Notifee.getInstance()
|
|
299
|
+
.getPowerManagerInfo(
|
|
300
|
+
(e, aBundle) -> NotifeeReactUtils.promiseResolver(promise, e, aBundle));
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@ReactMethod
|
|
304
|
+
public void openPowerManagerSettings(Promise promise) {
|
|
305
|
+
Notifee.getInstance()
|
|
306
|
+
.openPowerManagerSettings(
|
|
307
|
+
getCurrentActivity(), (e, avoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
@ReactMethod
|
|
311
|
+
public void stopForegroundService(Promise promise) {
|
|
312
|
+
Notifee.getInstance()
|
|
313
|
+
.stopForegroundService((e, aVoid) -> NotifeeReactUtils.promiseResolver(promise, e));
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@ReactMethod
|
|
317
|
+
public void hideNotificationDrawer() {
|
|
318
|
+
NotifeeReactUtils.hideNotificationDrawer();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@ReactMethod
|
|
322
|
+
public void addListener(String eventName) {
|
|
323
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
@ReactMethod
|
|
327
|
+
public void removeListeners(Integer count) {
|
|
328
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
@NonNull
|
|
332
|
+
@Override
|
|
333
|
+
public String getName() {
|
|
334
|
+
return "NotifeeApiModule";
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
@Override
|
|
338
|
+
public Map<String, Object> getConstants() {
|
|
339
|
+
Map<String, Object> constants = new HashMap<>();
|
|
340
|
+
constants.put("ANDROID_API_LEVEL", android.os.Build.VERSION.SDK_INT);
|
|
341
|
+
return constants;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
@Override
|
|
345
|
+
public boolean onRequestPermissionsResult(
|
|
346
|
+
int requestCode, String[] permissions, int[] grantResults) {
|
|
347
|
+
return Notifee.getInstance().onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
package io.invertase.notifee;
|
|
6
|
+
|
|
7
|
+
import static io.invertase.notifee.NotifeeReactUtils.isAppInForeground;
|
|
8
|
+
|
|
9
|
+
import android.os.Bundle;
|
|
10
|
+
import androidx.annotation.Keep;
|
|
11
|
+
import app.notifee.core.event.BlockStateEvent;
|
|
12
|
+
import app.notifee.core.event.ForegroundServiceEvent;
|
|
13
|
+
import app.notifee.core.event.LogEvent;
|
|
14
|
+
import app.notifee.core.event.NotificationEvent;
|
|
15
|
+
import app.notifee.core.interfaces.EventListener;
|
|
16
|
+
import app.notifee.core.model.NotificationModel;
|
|
17
|
+
import com.facebook.react.bridge.Arguments;
|
|
18
|
+
import com.facebook.react.bridge.WritableMap;
|
|
19
|
+
|
|
20
|
+
@Keep
|
|
21
|
+
public class NotifeeEventSubscriber implements EventListener {
|
|
22
|
+
static final String NOTIFICATION_EVENT_KEY = "app.notifee.notification-event";
|
|
23
|
+
static final String FOREGROUND_NOTIFICATION_TASK_KEY =
|
|
24
|
+
"app.notifee.foreground-service-headless-task";
|
|
25
|
+
|
|
26
|
+
private static final String KEY_TYPE = "type";
|
|
27
|
+
private static final String KEY_DETAIL = "detail";
|
|
28
|
+
private static final String KEY_BLOCKED = "blocked";
|
|
29
|
+
private static final String KEY_HEADLESS = "headless";
|
|
30
|
+
private static final String KEY_NOTIFICATION = "notification";
|
|
31
|
+
|
|
32
|
+
private static final String KEY_DETAIL_PRESS_ACTION = "pressAction";
|
|
33
|
+
private static final String KEY_DETAIL_INPUT = "input";
|
|
34
|
+
|
|
35
|
+
@Override
|
|
36
|
+
public void onNotificationEvent(NotificationEvent notificationEvent) {
|
|
37
|
+
WritableMap eventMap = Arguments.createMap();
|
|
38
|
+
WritableMap eventDetailMap = Arguments.createMap();
|
|
39
|
+
eventMap.putInt(KEY_TYPE, notificationEvent.getType());
|
|
40
|
+
|
|
41
|
+
eventDetailMap.putMap(
|
|
42
|
+
KEY_NOTIFICATION, Arguments.fromBundle(notificationEvent.getNotification().toBundle()));
|
|
43
|
+
|
|
44
|
+
Bundle extras = notificationEvent.getExtras();
|
|
45
|
+
if (extras != null) {
|
|
46
|
+
Bundle pressAction = extras.getBundle(KEY_DETAIL_PRESS_ACTION);
|
|
47
|
+
if (pressAction != null) {
|
|
48
|
+
eventDetailMap.putMap(KEY_DETAIL_PRESS_ACTION, Arguments.fromBundle(pressAction));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
String input = extras.getString(KEY_DETAIL_INPUT);
|
|
52
|
+
if (input != null) {
|
|
53
|
+
eventDetailMap.putString(KEY_DETAIL_INPUT, input);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
eventMap.putMap(KEY_DETAIL, eventDetailMap);
|
|
58
|
+
|
|
59
|
+
if (isAppInForeground()) {
|
|
60
|
+
eventMap.putBoolean(KEY_HEADLESS, false);
|
|
61
|
+
NotifeeReactUtils.sendEvent(NOTIFICATION_EVENT_KEY, eventMap);
|
|
62
|
+
} else {
|
|
63
|
+
eventMap.putBoolean(KEY_HEADLESS, true);
|
|
64
|
+
NotifeeReactUtils.startHeadlessTask(NOTIFICATION_EVENT_KEY, eventMap, 60000, null);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Override
|
|
69
|
+
public void onLogEvent(LogEvent logEvent) {
|
|
70
|
+
// TODO
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@Override
|
|
74
|
+
public void onBlockStateEvent(BlockStateEvent blockStateEvent) {
|
|
75
|
+
WritableMap eventMap = Arguments.createMap();
|
|
76
|
+
WritableMap eventDetailMap = Arguments.createMap();
|
|
77
|
+
|
|
78
|
+
eventMap.putInt(KEY_TYPE, blockStateEvent.getType());
|
|
79
|
+
|
|
80
|
+
int type = blockStateEvent.getType();
|
|
81
|
+
|
|
82
|
+
if (type == BlockStateEvent.TYPE_CHANNEL_BLOCKED
|
|
83
|
+
|| type == BlockStateEvent.TYPE_CHANNEL_GROUP_BLOCKED) {
|
|
84
|
+
String mapKey = type == BlockStateEvent.TYPE_CHANNEL_BLOCKED ? "channel" : "channelGroup";
|
|
85
|
+
Bundle channelOrGroupBundle = blockStateEvent.getChannelOrGroupBundle();
|
|
86
|
+
if (channelOrGroupBundle != null) {
|
|
87
|
+
eventDetailMap.putMap(
|
|
88
|
+
mapKey, Arguments.fromBundle(blockStateEvent.getChannelOrGroupBundle()));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (type == BlockStateEvent.TYPE_APP_BLOCKED) {
|
|
93
|
+
eventDetailMap.putBoolean(KEY_BLOCKED, blockStateEvent.isBlocked());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
eventMap.putMap(KEY_DETAIL, eventDetailMap);
|
|
97
|
+
|
|
98
|
+
if (isAppInForeground()) {
|
|
99
|
+
eventMap.putBoolean(KEY_HEADLESS, false);
|
|
100
|
+
NotifeeReactUtils.sendEvent(NOTIFICATION_EVENT_KEY, eventMap);
|
|
101
|
+
} else {
|
|
102
|
+
eventMap.putBoolean(KEY_HEADLESS, true);
|
|
103
|
+
NotifeeReactUtils.startHeadlessTask(
|
|
104
|
+
NOTIFICATION_EVENT_KEY, eventMap, 0, blockStateEvent::setCompletionResult);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@Override
|
|
109
|
+
public void onForegroundServiceEvent(ForegroundServiceEvent foregroundServiceEvent) {
|
|
110
|
+
NotificationModel notificationBundle = foregroundServiceEvent.getNotification();
|
|
111
|
+
|
|
112
|
+
WritableMap eventMap = Arguments.createMap();
|
|
113
|
+
eventMap.putMap(KEY_NOTIFICATION, Arguments.fromBundle(notificationBundle.toBundle()));
|
|
114
|
+
|
|
115
|
+
NotifeeReactUtils.startHeadlessTask(
|
|
116
|
+
FOREGROUND_NOTIFICATION_TASK_KEY, eventMap, 0, foregroundServiceEvent::setCompletionResult);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
package io.invertase.notifee;
|
|
6
|
+
|
|
7
|
+
import android.content.Context;
|
|
8
|
+
import android.content.pm.PackageInfo;
|
|
9
|
+
import android.content.pm.PackageManager;
|
|
10
|
+
import app.notifee.core.InitProvider;
|
|
11
|
+
import app.notifee.core.Notifee;
|
|
12
|
+
import com.facebook.react.modules.systeminfo.ReactNativeVersion;
|
|
13
|
+
import java.util.Map;
|
|
14
|
+
|
|
15
|
+
public class NotifeeInitProvider extends InitProvider {
|
|
16
|
+
@Override
|
|
17
|
+
public boolean onCreate() {
|
|
18
|
+
boolean onCreate = super.onCreate();
|
|
19
|
+
|
|
20
|
+
Notifee.initialize(new NotifeeEventSubscriber());
|
|
21
|
+
return onCreate;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private String getApplicationVersionString() {
|
|
25
|
+
String version = "unknown";
|
|
26
|
+
Context context = this.getContext();
|
|
27
|
+
if (context != null) {
|
|
28
|
+
PackageManager pm = context.getPackageManager();
|
|
29
|
+
try {
|
|
30
|
+
PackageInfo pInfo = pm.getPackageInfo(context.getPackageName(), 0);
|
|
31
|
+
version = pInfo.versionName;
|
|
32
|
+
} catch (Exception e) {
|
|
33
|
+
// is there anything useful to log the unbelievably unexpected inability to get package
|
|
34
|
+
// info?
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return version;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private String getReactNativeVersionString() {
|
|
42
|
+
Map<String, Object> versionMap = ReactNativeVersion.VERSION;
|
|
43
|
+
int major = (int) versionMap.get("major");
|
|
44
|
+
int minor = (int) versionMap.get("minor");
|
|
45
|
+
int patch = (int) versionMap.get("patch");
|
|
46
|
+
String prerelease = (String) versionMap.get("prerelease");
|
|
47
|
+
|
|
48
|
+
String versionName = major + "." + minor + "." + patch;
|
|
49
|
+
if (prerelease != null) {
|
|
50
|
+
versionName += "." + prerelease;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return versionName;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
package io.invertase.notifee;
|
|
6
|
+
|
|
7
|
+
import com.facebook.react.ReactPackage;
|
|
8
|
+
import com.facebook.react.bridge.NativeModule;
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
11
|
+
import java.util.ArrayList;
|
|
12
|
+
import java.util.Collections;
|
|
13
|
+
import java.util.List;
|
|
14
|
+
import javax.annotation.Nonnull;
|
|
15
|
+
|
|
16
|
+
public class NotifeePackage implements ReactPackage {
|
|
17
|
+
@Nonnull
|
|
18
|
+
@Override
|
|
19
|
+
public List<NativeModule> createNativeModules(@Nonnull ReactApplicationContext reactContext) {
|
|
20
|
+
List<NativeModule> modules = new ArrayList<>();
|
|
21
|
+
modules.add(new NotifeeApiModule(reactContext));
|
|
22
|
+
return modules;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Nonnull
|
|
26
|
+
@Override
|
|
27
|
+
public List<ViewManager> createViewManagers(@Nonnull ReactApplicationContext reactContext) {
|
|
28
|
+
return Collections.emptyList();
|
|
29
|
+
}
|
|
30
|
+
}
|