@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,244 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
package io.invertase.notifee;
|
|
6
|
+
|
|
7
|
+
import android.annotation.SuppressLint;
|
|
8
|
+
import android.app.ActivityManager;
|
|
9
|
+
import android.content.Context;
|
|
10
|
+
import android.os.Build;
|
|
11
|
+
import android.os.Bundle;
|
|
12
|
+
import android.os.Handler;
|
|
13
|
+
import android.os.Looper;
|
|
14
|
+
import android.util.Log;
|
|
15
|
+
import android.util.SparseArray;
|
|
16
|
+
import androidx.annotation.Nullable;
|
|
17
|
+
import app.notifee.core.EventSubscriber;
|
|
18
|
+
import com.facebook.react.ReactApplication;
|
|
19
|
+
import com.facebook.react.ReactInstanceManager;
|
|
20
|
+
import com.facebook.react.ReactNativeHost;
|
|
21
|
+
import com.facebook.react.bridge.Arguments;
|
|
22
|
+
import com.facebook.react.bridge.Promise;
|
|
23
|
+
import com.facebook.react.bridge.ReactContext;
|
|
24
|
+
import com.facebook.react.bridge.WritableArray;
|
|
25
|
+
import com.facebook.react.bridge.WritableMap;
|
|
26
|
+
import com.facebook.react.common.LifecycleState;
|
|
27
|
+
import com.facebook.react.jstasks.HeadlessJsTaskConfig;
|
|
28
|
+
import com.facebook.react.jstasks.HeadlessJsTaskContext;
|
|
29
|
+
import com.facebook.react.jstasks.HeadlessJsTaskEventListener;
|
|
30
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
31
|
+
import java.lang.reflect.Method;
|
|
32
|
+
import java.util.List;
|
|
33
|
+
|
|
34
|
+
class NotifeeReactUtils {
|
|
35
|
+
private static final SparseArray<GenericCallback> headlessTasks = new SparseArray<>();
|
|
36
|
+
private static final HeadlessJsTaskEventListener headlessTasksListener =
|
|
37
|
+
new HeadlessJsTaskEventListener() {
|
|
38
|
+
@Override
|
|
39
|
+
public void onHeadlessJsTaskStart(int taskId) {}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
public void onHeadlessJsTaskFinish(int taskId) {
|
|
43
|
+
synchronized (headlessTasks) {
|
|
44
|
+
GenericCallback callback = headlessTasks.get(taskId);
|
|
45
|
+
if (callback != null) {
|
|
46
|
+
headlessTasks.remove(taskId);
|
|
47
|
+
callback.call();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
static void promiseResolver(Promise promise, Exception e, Bundle bundle) {
|
|
54
|
+
if (e != null) {
|
|
55
|
+
// TODO custom error class with message/code
|
|
56
|
+
promise.reject(e);
|
|
57
|
+
} else if (bundle != null) {
|
|
58
|
+
promise.resolve(Arguments.fromBundle(bundle));
|
|
59
|
+
} else {
|
|
60
|
+
promise.resolve(null);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static void promiseResolver(Promise promise, Exception e, List<Bundle> bundleList) {
|
|
65
|
+
if (e != null) {
|
|
66
|
+
// TODO custom error class with message/code
|
|
67
|
+
promise.reject(e);
|
|
68
|
+
} else {
|
|
69
|
+
WritableArray writableArray = Arguments.createArray();
|
|
70
|
+
for (Bundle bundle : bundleList) {
|
|
71
|
+
writableArray.pushMap(Arguments.fromBundle(bundle));
|
|
72
|
+
}
|
|
73
|
+
promise.resolve(writableArray);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static void promiseBooleanResolver(Promise promise, Exception e, Boolean bool) {
|
|
78
|
+
if (e != null) {
|
|
79
|
+
// TODO custom error class with message/code
|
|
80
|
+
promise.reject(e);
|
|
81
|
+
} else {
|
|
82
|
+
promise.resolve(bool);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static void promiseStringListResolver(Promise promise, Exception e, List<String> stringList) {
|
|
87
|
+
if (e != null) {
|
|
88
|
+
// TODO custom error class with message/code
|
|
89
|
+
promise.reject(e);
|
|
90
|
+
} else {
|
|
91
|
+
WritableArray writableArray = Arguments.createArray();
|
|
92
|
+
for (String string : stringList) {
|
|
93
|
+
writableArray.pushString(string);
|
|
94
|
+
}
|
|
95
|
+
promise.resolve(writableArray);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static void promiseResolver(Promise promise, Exception e) {
|
|
100
|
+
if (e != null) {
|
|
101
|
+
// TODO custom error class with message/code
|
|
102
|
+
promise.reject(e);
|
|
103
|
+
} else {
|
|
104
|
+
promise.resolve(null);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private static @Nullable ReactContext getReactContext() {
|
|
109
|
+
ReactNativeHost reactNativeHost =
|
|
110
|
+
((ReactApplication) EventSubscriber.getContext()).getReactNativeHost();
|
|
111
|
+
ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
|
|
112
|
+
return reactInstanceManager.getCurrentReactContext();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private static void initializeReactContext(GenericCallback callback) {
|
|
116
|
+
ReactNativeHost reactNativeHost =
|
|
117
|
+
((ReactApplication) EventSubscriber.getContext()).getReactNativeHost();
|
|
118
|
+
|
|
119
|
+
ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
|
|
120
|
+
|
|
121
|
+
reactInstanceManager.addReactInstanceEventListener(
|
|
122
|
+
new ReactInstanceManager.ReactInstanceEventListener() {
|
|
123
|
+
@Override
|
|
124
|
+
public void onReactContextInitialized(final ReactContext reactContext) {
|
|
125
|
+
reactInstanceManager.removeReactInstanceEventListener(this);
|
|
126
|
+
new Handler(Looper.getMainLooper()).postDelayed(callback::call, 100);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
if (!reactInstanceManager.hasStartedCreatingInitialContext()) {
|
|
131
|
+
reactInstanceManager.createReactContextInBackground();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static void clearRunningHeadlessTasks() {
|
|
136
|
+
for (int i = 0; i < headlessTasks.size(); i++) {
|
|
137
|
+
GenericCallback callback = headlessTasks.valueAt(i);
|
|
138
|
+
callback.call();
|
|
139
|
+
headlessTasks.remove(i);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static void startHeadlessTask(
|
|
144
|
+
String taskName,
|
|
145
|
+
WritableMap taskData,
|
|
146
|
+
long taskTimeout,
|
|
147
|
+
@Nullable GenericCallback taskCompletionCallback) {
|
|
148
|
+
GenericCallback callback =
|
|
149
|
+
() -> {
|
|
150
|
+
HeadlessJsTaskContext taskContext = HeadlessJsTaskContext.getInstance(getReactContext());
|
|
151
|
+
HeadlessJsTaskConfig taskConfig =
|
|
152
|
+
new HeadlessJsTaskConfig(taskName, taskData, taskTimeout, true);
|
|
153
|
+
|
|
154
|
+
synchronized (headlessTasks) {
|
|
155
|
+
if (headlessTasks.size() == 0) {
|
|
156
|
+
taskContext.addTaskEventListener(headlessTasksListener);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
headlessTasks.put(
|
|
161
|
+
taskContext.startTask(taskConfig),
|
|
162
|
+
() -> {
|
|
163
|
+
synchronized (headlessTasks) {
|
|
164
|
+
if (headlessTasks.size() == 0) {
|
|
165
|
+
taskContext.removeTaskEventListener(headlessTasksListener);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (taskCompletionCallback != null) {
|
|
169
|
+
taskCompletionCallback.call();
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
if (getReactContext() == null) {
|
|
175
|
+
initializeReactContext(callback);
|
|
176
|
+
} else {
|
|
177
|
+
callback.call();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
static void sendEvent(String eventName, WritableMap eventMap) {
|
|
182
|
+
try {
|
|
183
|
+
ReactContext reactContext = getReactContext();
|
|
184
|
+
|
|
185
|
+
if (reactContext == null || !reactContext.hasActiveCatalystInstance()) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
reactContext
|
|
190
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
191
|
+
.emit(eventName, eventMap);
|
|
192
|
+
|
|
193
|
+
} catch (Exception e) {
|
|
194
|
+
Log.e("SEND_EVENT", "", e);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
static boolean isAppInForeground() {
|
|
199
|
+
Context context = EventSubscriber.getContext();
|
|
200
|
+
|
|
201
|
+
ActivityManager activityManager =
|
|
202
|
+
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
|
203
|
+
if (activityManager == null) return false;
|
|
204
|
+
|
|
205
|
+
List<ActivityManager.RunningAppProcessInfo> appProcesses =
|
|
206
|
+
activityManager.getRunningAppProcesses();
|
|
207
|
+
if (appProcesses == null) return false;
|
|
208
|
+
|
|
209
|
+
final String packageName = context.getPackageName();
|
|
210
|
+
for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
|
|
211
|
+
if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
|
|
212
|
+
&& appProcess.processName.equals(packageName)) {
|
|
213
|
+
ReactContext reactContext = getReactContext();
|
|
214
|
+
if (reactContext == null) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return reactContext.getLifecycleState() == LifecycleState.RESUMED;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
static void hideNotificationDrawer() {
|
|
226
|
+
Context context = EventSubscriber.getContext();
|
|
227
|
+
|
|
228
|
+
try {
|
|
229
|
+
@SuppressLint("WrongConstant")
|
|
230
|
+
Object service = context.getSystemService("statusbar");
|
|
231
|
+
Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
|
|
232
|
+
Method collapse =
|
|
233
|
+
statusbarManager.getMethod((Build.VERSION.SDK_INT >= 17) ? "collapsePanels" : "collapse");
|
|
234
|
+
collapse.setAccessible(true);
|
|
235
|
+
collapse.invoke(service);
|
|
236
|
+
} catch (Exception e) {
|
|
237
|
+
Log.e("HIDE_NOTIF_DRAWER", "", e);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
interface GenericCallback {
|
|
242
|
+
void call();
|
|
243
|
+
}
|
|
244
|
+
}
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./plugin/build');
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Module } from './types/Module';
|
|
2
|
+
import { AndroidChannel, AndroidChannelGroup, NativeAndroidChannel, NativeAndroidChannelGroup } from './types/NotificationAndroid';
|
|
3
|
+
import { InitialNotification, Notification, Event, TriggerNotification, DisplayedNotification, NotificationSettings } from './types/Notification';
|
|
4
|
+
import { PowerManagerInfo } from './types/PowerManagerInfo';
|
|
5
|
+
import { Trigger } from './types/Trigger';
|
|
6
|
+
import NotifeeNativeModule, { NativeModuleConfig } from './NotifeeNativeModule';
|
|
7
|
+
import { IOSNotificationCategory, IOSNotificationPermissions } from './types/NotificationIOS';
|
|
8
|
+
export default class NotifeeApiModule extends NotifeeNativeModule implements Module {
|
|
9
|
+
constructor(config: NativeModuleConfig);
|
|
10
|
+
getTriggerNotificationIds: () => Promise<string[]>;
|
|
11
|
+
getTriggerNotifications: () => Promise<TriggerNotification[]>;
|
|
12
|
+
getDisplayedNotifications: () => Promise<DisplayedNotification[]>;
|
|
13
|
+
isChannelBlocked: (channelId: string) => Promise<boolean>;
|
|
14
|
+
isChannelCreated: (channelId: string) => Promise<boolean>;
|
|
15
|
+
cancelAllNotifications: (notificationIds?: string[], tag?: string) => Promise<void>;
|
|
16
|
+
cancelDisplayedNotifications: (notificationIds?: string[], tag?: string) => Promise<void>;
|
|
17
|
+
cancelTriggerNotifications: (notificationIds?: string[]) => Promise<void>;
|
|
18
|
+
cancelNotification: (notificationId: string, tag?: string) => Promise<void>;
|
|
19
|
+
cancelDisplayedNotification: (notificationId: string, tag?: string) => Promise<void>;
|
|
20
|
+
cancelTriggerNotification: (notificationId: string) => Promise<void>;
|
|
21
|
+
createChannel: (channel: AndroidChannel) => Promise<string>;
|
|
22
|
+
createChannels: (channels: AndroidChannel[]) => Promise<void>;
|
|
23
|
+
createChannelGroup: (channelGroup: AndroidChannelGroup) => Promise<string>;
|
|
24
|
+
createChannelGroups: (channelGroups: AndroidChannelGroup[]) => Promise<void>;
|
|
25
|
+
deleteChannel: (channelId: string) => Promise<void>;
|
|
26
|
+
deleteChannelGroup: (channelGroupId: string) => Promise<void>;
|
|
27
|
+
displayNotification: (notification: Notification) => Promise<string>;
|
|
28
|
+
openAlarmPermissionSettings: () => Promise<void>;
|
|
29
|
+
createTriggerNotification: (notification: Notification, trigger: Trigger) => Promise<string>;
|
|
30
|
+
getChannel: (channelId: string) => Promise<NativeAndroidChannel | null>;
|
|
31
|
+
getChannels: () => Promise<NativeAndroidChannel[]>;
|
|
32
|
+
getChannelGroup: (channelGroupId: string) => Promise<NativeAndroidChannelGroup | null>;
|
|
33
|
+
getChannelGroups: () => Promise<NativeAndroidChannelGroup[]>;
|
|
34
|
+
getInitialNotification: () => Promise<InitialNotification | null>;
|
|
35
|
+
onBackgroundEvent: (observer: (event: Event) => Promise<void>) => void;
|
|
36
|
+
onForegroundEvent: (observer: (event: Event) => void) => (() => void);
|
|
37
|
+
openNotificationSettings: (channelId?: string) => Promise<void>;
|
|
38
|
+
requestPermission: (permissions?: IOSNotificationPermissions) => Promise<NotificationSettings>;
|
|
39
|
+
registerForegroundService(runner: (notification: Notification) => Promise<void>): void;
|
|
40
|
+
setNotificationCategories: (categories: IOSNotificationCategory[]) => Promise<void>;
|
|
41
|
+
getNotificationCategories: () => Promise<IOSNotificationCategory[]>;
|
|
42
|
+
getNotificationSettings: () => Promise<NotificationSettings>;
|
|
43
|
+
getBadgeCount: () => Promise<number>;
|
|
44
|
+
setBadgeCount: (count: number) => Promise<void>;
|
|
45
|
+
incrementBadgeCount: (incrementBy?: number) => Promise<void>;
|
|
46
|
+
decrementBadgeCount: (decrementBy?: number) => Promise<void>;
|
|
47
|
+
isBatteryOptimizationEnabled: () => Promise<boolean>;
|
|
48
|
+
openBatteryOptimizationSettings: () => Promise<void>;
|
|
49
|
+
getPowerManagerInfo: () => Promise<PowerManagerInfo>;
|
|
50
|
+
openPowerManagerSettings: () => Promise<void>;
|
|
51
|
+
stopForegroundService: () => Promise<void>;
|
|
52
|
+
hideNotificationDrawer: () => void;
|
|
53
|
+
}
|