react-native-notify-kit 9.1.8
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/LICENSE +44 -0
- package/README.md +212 -0
- package/RNNotifee.podspec +37 -0
- package/RNNotifeeCore.podspec +32 -0
- package/android/.editorconfig +10 -0
- package/android/build.gradle +117 -0
- package/android/gradle.properties +1 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar +0 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.md5 +1 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha1 +1 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha256 +1 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.aar.sha512 +1 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.pom +9 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.md5 +1 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.sha1 +1 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.pom.sha256 +1 -0
- package/android/libs/app/notifee/core/202108261754/core-202108261754.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 +82 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +12 -0
- package/android/src/main/kotlin/io/invertase/notifee/HeadlessTask.kt +257 -0
- package/android/src/main/kotlin/io/invertase/notifee/NotifeeApiModule.kt +392 -0
- package/android/src/main/kotlin/io/invertase/notifee/NotifeeEventSubscriber.kt +117 -0
- package/android/src/main/kotlin/io/invertase/notifee/NotifeeInitProvider.kt +43 -0
- package/android/src/main/kotlin/io/invertase/notifee/NotifeePackage.kt +37 -0
- package/android/src/main/kotlin/io/invertase/notifee/NotifeeReactUtils.kt +118 -0
- package/dist/NotifeeApiModule.d.ts +53 -0
- package/dist/NotifeeApiModule.js +593 -0
- package/dist/NotifeeApiModule.js.map +1 -0
- package/dist/NotifeeJSEventEmitter.d.ts +3 -0
- package/dist/NotifeeJSEventEmitter.js +9 -0
- package/dist/NotifeeJSEventEmitter.js.map +1 -0
- package/dist/NotifeeNativeError.d.ts +15 -0
- package/dist/NotifeeNativeError.js +56 -0
- package/dist/NotifeeNativeError.js.map +1 -0
- package/dist/NotifeeNativeModule.d.ts +13 -0
- package/dist/NotifeeNativeModule.js +27 -0
- package/dist/NotifeeNativeModule.js.map +1 -0
- package/dist/NotifeeNativeModule.web.d.ts +12 -0
- package/dist/NotifeeNativeModule.web.js +15 -0
- package/dist/NotifeeNativeModule.web.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/specs/NativeNotifeeModule.d.ts +53 -0
- package/dist/specs/NativeNotifeeModule.js +6 -0
- package/dist/specs/NativeNotifeeModule.js.map +1 -0
- package/dist/types/Library.d.ts +21 -0
- package/dist/types/Library.js +5 -0
- package/dist/types/Library.js.map +1 -0
- package/dist/types/Module.d.ts +576 -0
- package/dist/types/Module.js +5 -0
- package/dist/types/Module.js.map +1 -0
- package/dist/types/Notification.d.ts +462 -0
- package/dist/types/Notification.js +108 -0
- package/dist/types/Notification.js.map +1 -0
- package/dist/types/NotificationAndroid.d.ts +1311 -0
- package/dist/types/NotificationAndroid.js +406 -0
- package/dist/types/NotificationAndroid.js.map +1 -0
- package/dist/types/NotificationIOS.d.ts +539 -0
- package/dist/types/NotificationIOS.js +89 -0
- package/dist/types/NotificationIOS.js.map +1 -0
- package/dist/types/NotificationWeb.d.ts +5 -0
- package/dist/types/NotificationWeb.js +5 -0
- package/dist/types/NotificationWeb.js.map +1 -0
- package/dist/types/PowerManagerInfo.d.ts +36 -0
- package/dist/types/PowerManagerInfo.js +5 -0
- package/dist/types/PowerManagerInfo.js.map +1 -0
- package/dist/types/Trigger.d.ts +124 -0
- package/dist/types/Trigger.js +48 -0
- package/dist/types/Trigger.js.map +1 -0
- package/dist/utils/id.d.ts +1 -0
- package/dist/utils/id.js +12 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/utils/index.d.ts +16 -0
- package/dist/utils/index.js +31 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validate.d.ts +15 -0
- package/dist/utils/validate.js +75 -0
- package/dist/utils/validate.js.map +1 -0
- package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.d.ts +2 -0
- package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfo.js +45 -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 +24 -0
- package/dist/validators/iosCommunicationInfo/validateIOSCommunicationInfoPerson.js.map +1 -0
- package/dist/validators/validate.d.ts +25 -0
- package/dist/validators/validate.js +68 -0
- package/dist/validators/validate.js.map +1 -0
- package/dist/validators/validateAndroidAction.d.ts +2 -0
- package/dist/validators/validateAndroidAction.js +46 -0
- package/dist/validators/validateAndroidAction.js.map +1 -0
- package/dist/validators/validateAndroidChannel.d.ts +2 -0
- package/dist/validators/validateAndroidChannel.js +152 -0
- package/dist/validators/validateAndroidChannel.js.map +1 -0
- package/dist/validators/validateAndroidChannelGroup.d.ts +2 -0
- package/dist/validators/validateAndroidChannelGroup.js +39 -0
- package/dist/validators/validateAndroidChannelGroup.js.map +1 -0
- package/dist/validators/validateAndroidFullScreenAction.d.ts +2 -0
- package/dist/validators/validateAndroidFullScreenAction.js +47 -0
- package/dist/validators/validateAndroidFullScreenAction.js.map +1 -0
- package/dist/validators/validateAndroidInput.d.ts +2 -0
- package/dist/validators/validateAndroidInput.js +51 -0
- package/dist/validators/validateAndroidInput.js.map +1 -0
- package/dist/validators/validateAndroidNotification.d.ts +2 -0
- package/dist/validators/validateAndroidNotification.js +541 -0
- package/dist/validators/validateAndroidNotification.js.map +1 -0
- package/dist/validators/validateAndroidPressAction.d.ts +2 -0
- package/dist/validators/validateAndroidPressAction.js +47 -0
- package/dist/validators/validateAndroidPressAction.js.map +1 -0
- package/dist/validators/validateAndroidStyle.d.ts +22 -0
- package/dist/validators/validateAndroidStyle.js +222 -0
- package/dist/validators/validateAndroidStyle.js.map +1 -0
- package/dist/validators/validateIOSAttachment.d.ts +6 -0
- package/dist/validators/validateIOSAttachment.js +96 -0
- package/dist/validators/validateIOSAttachment.js.map +1 -0
- package/dist/validators/validateIOSCategory.d.ts +2 -0
- package/dist/validators/validateIOSCategory.js +118 -0
- package/dist/validators/validateIOSCategory.js.map +1 -0
- package/dist/validators/validateIOSCategoryAction.d.ts +2 -0
- package/dist/validators/validateIOSCategoryAction.js +53 -0
- package/dist/validators/validateIOSCategoryAction.js.map +1 -0
- package/dist/validators/validateIOSInput.d.ts +2 -0
- package/dist/validators/validateIOSInput.js +29 -0
- package/dist/validators/validateIOSInput.js.map +1 -0
- package/dist/validators/validateIOSNotification.d.ts +2 -0
- package/dist/validators/validateIOSNotification.js +205 -0
- package/dist/validators/validateIOSNotification.js.map +1 -0
- package/dist/validators/validateIOSPermissions.d.ts +2 -0
- package/dist/validators/validateIOSPermissions.js +59 -0
- package/dist/validators/validateIOSPermissions.js.map +1 -0
- package/dist/validators/validateNotification.d.ts +11 -0
- package/dist/validators/validateNotification.js +121 -0
- package/dist/validators/validateNotification.js.map +1 -0
- package/dist/validators/validateTrigger.d.ts +2 -0
- package/dist/validators/validateTrigger.js +107 -0
- package/dist/validators/validateTrigger.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +3 -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 +76 -0
- package/ios/NotifeeCore/NotifeeCore+NSURLSession.h +25 -0
- package/ios/NotifeeCore/NotifeeCore+NSURLSession.m +55 -0
- package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.h +44 -0
- package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +270 -0
- package/ios/NotifeeCore/NotifeeCore.h +118 -0
- package/ios/NotifeeCore/NotifeeCore.m +843 -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 +81 -0
- package/ios/NotifeeCore/NotifeeCoreUtil.m +834 -0
- package/ios/RNNotifee/NotifeeApiModule.h +25 -0
- package/ios/RNNotifee/NotifeeApiModule.mm +421 -0
- package/ios/RNNotifee/NotifeeExtensionHelper.h +37 -0
- package/ios/RNNotifee/NotifeeExtensionHelper.m +37 -0
- package/ios/RNNotifee.xcodeproj/project.pbxproj +318 -0
- package/ios/RNNotifee.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/RNNotifee.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/jest-mock.js +162 -0
- package/package.json +85 -0
- package/react-native.config.js +11 -0
- package/src/NotifeeApiModule.ts +823 -0
- package/src/NotifeeJSEventEmitter.ts +10 -0
- package/src/NotifeeNativeError.ts +68 -0
- package/src/NotifeeNativeModule.ts +39 -0
- package/src/NotifeeNativeModule.web.ts +25 -0
- package/src/index.ts +33 -0
- package/src/specs/NativeNotifeeModule.ts +71 -0
- package/src/types/Library.ts +28 -0
- package/src/types/Module.ts +629 -0
- package/src/types/Notification.ts +518 -0
- package/src/types/NotificationAndroid.ts +1478 -0
- package/src/types/NotificationIOS.ts +683 -0
- package/src/types/NotificationWeb.ts +5 -0
- package/src/types/PowerManagerInfo.ts +43 -0
- package/src/types/Trigger.ts +136 -0
- package/src/utils/id.ts +13 -0
- package/src/utils/index.ts +46 -0
- package/src/utils/validate.ts +90 -0
- package/src/validators/iosCommunicationInfo/validateIOSCommunicationInfo.ts +61 -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 +734 -0
- package/src/validators/validateAndroidPressAction.ts +65 -0
- package/src/validators/validateAndroidStyle.ts +315 -0
- package/src/validators/validateIOSAttachment.ts +135 -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 +142 -0
- package/src/version.ts +2 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
package io.invertase.notifee
|
|
6
|
+
|
|
7
|
+
import androidx.annotation.Keep
|
|
8
|
+
import app.notifee.core.event.BlockStateEvent
|
|
9
|
+
import app.notifee.core.event.ForegroundServiceEvent
|
|
10
|
+
import app.notifee.core.event.LogEvent
|
|
11
|
+
import app.notifee.core.event.NotificationEvent
|
|
12
|
+
import app.notifee.core.interfaces.EventListener
|
|
13
|
+
import com.facebook.react.bridge.Arguments
|
|
14
|
+
|
|
15
|
+
@Keep
|
|
16
|
+
class NotifeeEventSubscriber : EventListener {
|
|
17
|
+
|
|
18
|
+
companion object {
|
|
19
|
+
const val NOTIFICATION_EVENT_KEY = "app.notifee.notification-event"
|
|
20
|
+
const val FOREGROUND_NOTIFICATION_TASK_KEY = "app.notifee.foreground-service-headless-task"
|
|
21
|
+
|
|
22
|
+
private const val KEY_TYPE = "type"
|
|
23
|
+
private const val KEY_DETAIL = "detail"
|
|
24
|
+
private const val KEY_BLOCKED = "blocked"
|
|
25
|
+
private const val KEY_HEADLESS = "headless"
|
|
26
|
+
private const val KEY_NOTIFICATION = "notification"
|
|
27
|
+
private const val KEY_DETAIL_PRESS_ACTION = "pressAction"
|
|
28
|
+
private const val KEY_DETAIL_INPUT = "input"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override fun onNotificationEvent(notificationEvent: NotificationEvent) {
|
|
32
|
+
val eventMap = Arguments.createMap()
|
|
33
|
+
val eventDetailMap = Arguments.createMap()
|
|
34
|
+
eventMap.putInt(KEY_TYPE, notificationEvent.type)
|
|
35
|
+
|
|
36
|
+
eventDetailMap.putMap(
|
|
37
|
+
KEY_NOTIFICATION,
|
|
38
|
+
Arguments.fromBundle(notificationEvent.notification.toBundle()),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
notificationEvent.extras?.let { extras ->
|
|
42
|
+
extras.getBundle(KEY_DETAIL_PRESS_ACTION)?.let { pressAction ->
|
|
43
|
+
eventDetailMap.putMap(KEY_DETAIL_PRESS_ACTION, Arguments.fromBundle(pressAction))
|
|
44
|
+
}
|
|
45
|
+
extras.getString(KEY_DETAIL_INPUT)?.let { input ->
|
|
46
|
+
eventDetailMap.putString(KEY_DETAIL_INPUT, input)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
eventMap.putMap(KEY_DETAIL, eventDetailMap)
|
|
51
|
+
|
|
52
|
+
if (NotifeeReactUtils.isAppInForeground()) {
|
|
53
|
+
eventMap.putBoolean(KEY_HEADLESS, false)
|
|
54
|
+
NotifeeReactUtils.sendEvent(NOTIFICATION_EVENT_KEY, eventMap)
|
|
55
|
+
} else {
|
|
56
|
+
eventMap.putBoolean(KEY_HEADLESS, true)
|
|
57
|
+
NotifeeReactUtils.startHeadlessTask(NOTIFICATION_EVENT_KEY, eventMap, 60000, null)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
override fun onLogEvent(logEvent: LogEvent) {
|
|
62
|
+
// LogEvent callbacks are emitted by NotifeeCore logging, but the React Native layer
|
|
63
|
+
// does not currently forward them to JS or headless tasks, so this subscriber
|
|
64
|
+
// intentionally ignores them.
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
override fun onBlockStateEvent(blockStateEvent: BlockStateEvent) {
|
|
68
|
+
val eventMap = Arguments.createMap()
|
|
69
|
+
val eventDetailMap = Arguments.createMap()
|
|
70
|
+
|
|
71
|
+
val type = blockStateEvent.type
|
|
72
|
+
eventMap.putInt(KEY_TYPE, type)
|
|
73
|
+
|
|
74
|
+
if (type == BlockStateEvent.TYPE_CHANNEL_BLOCKED ||
|
|
75
|
+
type == BlockStateEvent.TYPE_CHANNEL_GROUP_BLOCKED
|
|
76
|
+
) {
|
|
77
|
+
val mapKey =
|
|
78
|
+
if (type == BlockStateEvent.TYPE_CHANNEL_BLOCKED) "channel" else "channelGroup"
|
|
79
|
+
blockStateEvent.channelOrGroupBundle?.let { bundle ->
|
|
80
|
+
eventDetailMap.putMap(mapKey, Arguments.fromBundle(bundle))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (type == BlockStateEvent.TYPE_APP_BLOCKED) {
|
|
85
|
+
eventDetailMap.putBoolean(KEY_BLOCKED, blockStateEvent.isBlocked)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
eventMap.putMap(KEY_DETAIL, eventDetailMap)
|
|
89
|
+
|
|
90
|
+
if (NotifeeReactUtils.isAppInForeground()) {
|
|
91
|
+
eventMap.putBoolean(KEY_HEADLESS, false)
|
|
92
|
+
NotifeeReactUtils.sendEvent(NOTIFICATION_EVENT_KEY, eventMap)
|
|
93
|
+
} else {
|
|
94
|
+
eventMap.putBoolean(KEY_HEADLESS, true)
|
|
95
|
+
NotifeeReactUtils.startHeadlessTask(
|
|
96
|
+
NOTIFICATION_EVENT_KEY,
|
|
97
|
+
eventMap,
|
|
98
|
+
0,
|
|
99
|
+
blockStateEvent::setCompletionResult,
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
override fun onForegroundServiceEvent(foregroundServiceEvent: ForegroundServiceEvent) {
|
|
105
|
+
val notificationBundle = foregroundServiceEvent.notification
|
|
106
|
+
|
|
107
|
+
val eventMap = Arguments.createMap()
|
|
108
|
+
eventMap.putMap(KEY_NOTIFICATION, Arguments.fromBundle(notificationBundle.toBundle()))
|
|
109
|
+
|
|
110
|
+
NotifeeReactUtils.startHeadlessTask(
|
|
111
|
+
FOREGROUND_NOTIFICATION_TASK_KEY,
|
|
112
|
+
eventMap,
|
|
113
|
+
0,
|
|
114
|
+
foregroundServiceEvent::setCompletionResult,
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
package io.invertase.notifee
|
|
6
|
+
|
|
7
|
+
import app.notifee.core.InitProvider
|
|
8
|
+
import app.notifee.core.Notifee
|
|
9
|
+
import com.facebook.react.modules.systeminfo.ReactNativeVersion
|
|
10
|
+
|
|
11
|
+
class NotifeeInitProvider : InitProvider() {
|
|
12
|
+
|
|
13
|
+
override fun onCreate(): Boolean {
|
|
14
|
+
val result = super.onCreate()
|
|
15
|
+
Notifee.initialize(NotifeeEventSubscriber())
|
|
16
|
+
return result
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private fun getApplicationVersionString(): String {
|
|
20
|
+
val context = this.context ?: return "unknown"
|
|
21
|
+
return try {
|
|
22
|
+
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
|
23
|
+
pInfo.versionName ?: "unknown"
|
|
24
|
+
} catch (e: Exception) {
|
|
25
|
+
"unknown"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private fun getReactNativeVersionString(): String {
|
|
30
|
+
val versionMap = ReactNativeVersion.VERSION
|
|
31
|
+
val major = versionMap["major"] as Int
|
|
32
|
+
val minor = versionMap["minor"] as Int
|
|
33
|
+
val patch = versionMap["patch"] as Int
|
|
34
|
+
val prerelease = versionMap["prerelease"] as? String
|
|
35
|
+
|
|
36
|
+
return buildString {
|
|
37
|
+
append("$major.$minor.$patch")
|
|
38
|
+
if (prerelease != null) {
|
|
39
|
+
append(".$prerelease")
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
package io.invertase.notifee
|
|
6
|
+
|
|
7
|
+
import com.facebook.react.BaseReactPackage
|
|
8
|
+
import com.facebook.react.bridge.NativeModule
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
10
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
11
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
12
|
+
|
|
13
|
+
class NotifeePackage : BaseReactPackage() {
|
|
14
|
+
|
|
15
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
16
|
+
return if (name == NotifeeApiModule.NAME) {
|
|
17
|
+
NotifeeApiModule(reactContext)
|
|
18
|
+
} else {
|
|
19
|
+
null
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
24
|
+
return ReactModuleInfoProvider {
|
|
25
|
+
mapOf(
|
|
26
|
+
NotifeeApiModule.NAME to ReactModuleInfo(
|
|
27
|
+
NotifeeApiModule.NAME,
|
|
28
|
+
NotifeeApiModule.NAME,
|
|
29
|
+
false, // canOverrideExistingModule
|
|
30
|
+
false, // needsEagerInit
|
|
31
|
+
false, // isCxxModule
|
|
32
|
+
true, // isTurboModule
|
|
33
|
+
),
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2016-present Invertase Limited
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
package io.invertase.notifee
|
|
6
|
+
|
|
7
|
+
import android.annotation.SuppressLint
|
|
8
|
+
import android.os.Build
|
|
9
|
+
import android.os.Bundle
|
|
10
|
+
import android.util.Log
|
|
11
|
+
import androidx.lifecycle.Lifecycle
|
|
12
|
+
import androidx.lifecycle.ProcessLifecycleOwner
|
|
13
|
+
import app.notifee.core.EventSubscriber
|
|
14
|
+
import com.facebook.react.bridge.Arguments
|
|
15
|
+
import com.facebook.react.bridge.Promise
|
|
16
|
+
import com.facebook.react.bridge.WritableArray
|
|
17
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
18
|
+
import java.lang.reflect.Method
|
|
19
|
+
|
|
20
|
+
object NotifeeReactUtils {
|
|
21
|
+
|
|
22
|
+
val headlessTaskManager = HeadlessTask()
|
|
23
|
+
|
|
24
|
+
fun promiseResolver(promise: Promise, e: Exception?, bundle: Bundle?) {
|
|
25
|
+
if (e != null) {
|
|
26
|
+
promise.reject(e)
|
|
27
|
+
} else if (bundle != null) {
|
|
28
|
+
promise.resolve(Arguments.fromBundle(bundle))
|
|
29
|
+
} else {
|
|
30
|
+
promise.resolve(null)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
fun promiseResolver(promise: Promise, e: Exception?, bundleList: List<Bundle>?) {
|
|
35
|
+
if (e != null) {
|
|
36
|
+
promise.reject(e)
|
|
37
|
+
} else {
|
|
38
|
+
val writableArray: WritableArray = Arguments.createArray()
|
|
39
|
+
bundleList?.forEach { bundle ->
|
|
40
|
+
writableArray.pushMap(Arguments.fromBundle(bundle))
|
|
41
|
+
}
|
|
42
|
+
promise.resolve(writableArray)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fun promiseBooleanResolver(promise: Promise, e: Exception?, value: Boolean?) {
|
|
47
|
+
if (e != null) {
|
|
48
|
+
promise.reject(e)
|
|
49
|
+
} else {
|
|
50
|
+
promise.resolve(value)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fun promiseStringListResolver(promise: Promise, e: Exception?, stringList: List<String>?) {
|
|
55
|
+
if (e != null) {
|
|
56
|
+
promise.reject(e)
|
|
57
|
+
} else {
|
|
58
|
+
val writableArray: WritableArray = Arguments.createArray()
|
|
59
|
+
stringList?.forEach { str ->
|
|
60
|
+
writableArray.pushString(str)
|
|
61
|
+
}
|
|
62
|
+
promise.resolve(writableArray)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fun promiseResolver(promise: Promise, e: Exception?) {
|
|
67
|
+
if (e != null) {
|
|
68
|
+
promise.reject(e)
|
|
69
|
+
} else {
|
|
70
|
+
promise.resolve(null)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
fun startHeadlessTask(
|
|
75
|
+
taskName: String,
|
|
76
|
+
taskData: com.facebook.react.bridge.WritableMap,
|
|
77
|
+
taskTimeout: Long,
|
|
78
|
+
taskCompletionCallback: HeadlessTask.GenericCallback?,
|
|
79
|
+
) {
|
|
80
|
+
val config = HeadlessTask.TaskConfig(taskName, taskTimeout, taskData, taskCompletionCallback)
|
|
81
|
+
headlessTaskManager.startTask(EventSubscriber.getContext(), config)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fun sendEvent(eventName: String, eventMap: com.facebook.react.bridge.WritableMap) {
|
|
85
|
+
try {
|
|
86
|
+
val reactContext = HeadlessTask.getReactContext(EventSubscriber.getContext()) ?: return
|
|
87
|
+
if (!reactContext.hasActiveReactInstance()) return
|
|
88
|
+
|
|
89
|
+
reactContext
|
|
90
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
91
|
+
.emit(eventName, eventMap)
|
|
92
|
+
} catch (e: Exception) {
|
|
93
|
+
Log.e("SEND_EVENT", "", e)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fun isAppInForeground(): Boolean {
|
|
98
|
+
return ProcessLifecycleOwner.get()
|
|
99
|
+
.lifecycle
|
|
100
|
+
.currentState
|
|
101
|
+
.isAtLeast(Lifecycle.State.RESUMED)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@SuppressLint("WrongConstant")
|
|
105
|
+
fun hideNotificationDrawer() {
|
|
106
|
+
val context = EventSubscriber.getContext()
|
|
107
|
+
try {
|
|
108
|
+
val service = context.getSystemService("statusbar")
|
|
109
|
+
val statusbarManager = Class.forName("android.app.StatusBarManager")
|
|
110
|
+
val methodName = if (Build.VERSION.SDK_INT >= 17) "collapsePanels" else "collapse"
|
|
111
|
+
val collapse: Method = statusbarManager.getMethod(methodName)
|
|
112
|
+
collapse.isAccessible = true
|
|
113
|
+
collapse.invoke(service)
|
|
114
|
+
} catch (e: Exception) {
|
|
115
|
+
Log.e("HIDE_NOTIF_DRAWER", "", e)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -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
|
+
}
|