@aws-amplify/rtn-push-notification 1.0.1-push-notification-dryrun.7810

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.
Files changed (48) hide show
  1. package/AmplifyRTNPushNotification.podspec +36 -0
  2. package/LICENSE +201 -0
  3. package/android/build.gradle +76 -0
  4. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  5. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  6. package/android/gradle.properties +23 -0
  7. package/android/gradlew +234 -0
  8. package/android/gradlew.bat +89 -0
  9. package/android/src/main/AndroidManifest.xml +22 -0
  10. package/android/src/main/kotlin/com/amazonaws/amplify/rtnpushnotification/PushNotificationAWSPinpointUtils.kt +159 -0
  11. package/android/src/main/kotlin/com/amazonaws/amplify/rtnpushnotification/PushNotificationEventManager.kt +49 -0
  12. package/android/src/main/kotlin/com/amazonaws/amplify/rtnpushnotification/PushNotificationFirebaseMessagingService.kt +74 -0
  13. package/android/src/main/kotlin/com/amazonaws/amplify/rtnpushnotification/PushNotificationHeadlessTaskService.kt +28 -0
  14. package/android/src/main/kotlin/com/amazonaws/amplify/rtnpushnotification/PushNotificationLaunchActivity.kt +27 -0
  15. package/android/src/main/kotlin/com/amazonaws/amplify/rtnpushnotification/PushNotificationModule.kt +188 -0
  16. package/android/src/main/kotlin/com/amazonaws/amplify/rtnpushnotification/PushNotificationPackage.kt +22 -0
  17. package/android/src/test/kotlin/PushNotificationAWSPinpointUtilsTest.kt +326 -0
  18. package/android/src/test/kotlin/PushNotificationEventManagerTest.kt +45 -0
  19. package/android/src/test/kotlin/PushNotificationFirebaseMessagingServiceTest.kt +92 -0
  20. package/android/src/test/kotlin/PushNotificationLaunchActivityTest.kt +45 -0
  21. package/android/src/test/kotlin/PushNotificationModuleTest.kt +201 -0
  22. package/ios/AmplifyPushNotification.h +17 -0
  23. package/ios/AmplifyPushNotification.m +21 -0
  24. package/ios/AmplifyPushNotificationAppDelegateHelper.swift +31 -0
  25. package/ios/AmplifyRTNEventManager.swift +73 -0
  26. package/ios/AmplifyRTNPushNotification-Bridging-Header.h +7 -0
  27. package/ios/AmplifyRTNPushNotification.m +26 -0
  28. package/ios/AmplifyRTNPushNotification.swift +121 -0
  29. package/ios/AmplifyRTNPushNotification.xcworkspace/contents.xcworkspacedata +28 -0
  30. package/ios/AmplifyRTNPushNotification.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  31. package/ios/AmplifyRTNPushNotificationManager.swift +258 -0
  32. package/lib/.tsbuildinfo +3 -0
  33. package/lib/index.d.ts +3 -0
  34. package/lib/index.js +7 -0
  35. package/lib/index.js.map +1 -0
  36. package/lib/types.d.ts +18 -0
  37. package/lib/types.js +5 -0
  38. package/lib/types.js.map +1 -0
  39. package/lib-esm/.tsbuildinfo +3 -0
  40. package/lib-esm/index.d.ts +3 -0
  41. package/lib-esm/index.js +5 -0
  42. package/lib-esm/index.js.map +1 -0
  43. package/lib-esm/types.d.ts +18 -0
  44. package/lib-esm/types.js +3 -0
  45. package/lib-esm/types.js.map +1 -0
  46. package/package.json +48 -0
  47. package/src/index.ts +10 -0
  48. package/src/types.ts +23 -0
@@ -0,0 +1,201 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import android.app.Activity
5
+ import android.content.Intent
6
+ import android.content.SharedPreferences
7
+ import androidx.core.app.ActivityCompat
8
+ import com.amazonaws.amplify.rtnpushnotification.*
9
+ import com.amplifyframework.annotations.InternalAmplifyApi
10
+ import com.amplifyframework.notifications.pushnotifications.NotificationContentProvider
11
+ import com.amplifyframework.notifications.pushnotifications.NotificationPayload
12
+ import com.facebook.react.bridge.Arguments
13
+ import com.facebook.react.bridge.Promise
14
+ import com.facebook.react.bridge.ReactApplicationContext
15
+ import com.facebook.react.bridge.WritableMap
16
+ import com.google.android.gms.tasks.OnCompleteListener
17
+ import com.google.android.gms.tasks.Task
18
+ import com.google.firebase.messaging.FirebaseMessaging
19
+ import io.mockk.*
20
+ import kotlinx.coroutines.ExperimentalCoroutinesApi
21
+ import kotlinx.coroutines.launch
22
+ import kotlinx.coroutines.runBlocking
23
+ import kotlinx.coroutines.test.StandardTestDispatcher
24
+ import kotlinx.coroutines.test.advanceUntilIdle
25
+ import kotlinx.coroutines.test.runTest
26
+ import org.junit.Assert.assertEquals
27
+ import org.junit.Assert.assertTrue
28
+ import org.junit.Before
29
+ import org.junit.Test
30
+ import org.junit.runner.RunWith
31
+ import org.robolectric.RobolectricTestRunner
32
+
33
+ @InternalAmplifyApi
34
+ @ExperimentalCoroutinesApi
35
+ @RunWith(RobolectricTestRunner::class)
36
+ class PushNotificationModuleTest {
37
+ private val mockContext = mockk<ReactApplicationContext>()
38
+ private val mockMap = mockk<WritableMap>()
39
+ private val mockPromise = mockk<Promise>()
40
+ private val mockSharedPreferences = mockk<SharedPreferences>()
41
+ private val mockTask = mockk<Task<String>>()
42
+ private val tokenOnCompleteListenerSlot = slot<OnCompleteListener<String>>()
43
+ private val testPayload = NotificationPayload.Builder(
44
+ NotificationContentProvider.FCM(emptyMap())
45
+ ).build()
46
+ private lateinit var module: PushNotificationModule
47
+
48
+ @Before
49
+ fun setup() {
50
+ mockkConstructor(PushNotificationPermission::class)
51
+ mockkObject(PushNotificationEventManager)
52
+ mockkObject(NotificationPayload)
53
+ mockkStatic(ActivityCompat::class)
54
+ mockkStatic(Arguments::class)
55
+ mockkStatic(FirebaseMessaging::class)
56
+ mockkStatic(NotificationPayload::toWritableMap)
57
+ mockkStatic(PushNotificationPermission::class)
58
+ mockkStatic(Task::class)
59
+ justRun {
60
+ mockContext.addActivityEventListener(any())
61
+ mockContext.addLifecycleEventListener(any())
62
+ PushNotificationEventManager.sendEvent(any(), any())
63
+ mockMap.putString(any(), any())
64
+ mockPromise.resolve(any())
65
+ }
66
+ every { mockContext.currentActivity?.intent } returns Intent()
67
+ every { mockContext.getSharedPreferences(any(), any()) } returns mockSharedPreferences
68
+ every { Arguments.createMap() } returns mockMap
69
+ every { FirebaseMessaging.getInstance().token } returns mockTask
70
+ every { NotificationPayload.fromIntent(any()) } returns testPayload
71
+ every { any<NotificationPayload>().toWritableMap() } returns mockMap
72
+ every { mockTask.isSuccessful } returns true
73
+ every { mockTask.result } returns "foo-bar"
74
+ every { mockTask.addOnCompleteListener(capture(tokenOnCompleteListenerSlot)) } answers {
75
+ tokenOnCompleteListenerSlot.captured.onComplete(mockTask)
76
+ mockTask
77
+ }
78
+ every { anyConstructed<PushNotificationPermission>().hasRequiredPermission } returns false
79
+ every { mockSharedPreferences.getBoolean(any(), any()) } returns false
80
+ every { ActivityCompat.shouldShowRequestPermissionRationale(any(), any()) } returns false
81
+ module = PushNotificationModule(mockContext)
82
+ }
83
+
84
+ @Test
85
+ fun `returns module name`() {
86
+ assertEquals("AmplifyRTNPushNotification", module.name)
87
+ }
88
+
89
+ @Test
90
+ fun `returns constants for use in JS`() {
91
+ assertTrue(module.constants.containsKey("NativeEvent"))
92
+ assertTrue(module.constants.containsKey("NativeHeadlessTaskKey"))
93
+ }
94
+
95
+ @Test
96
+ fun `onNewIntent does nothing if intent does not contain payload`() {
97
+ every { NotificationPayload.fromIntent(any()) } returns null
98
+ module.onNewIntent(Intent())
99
+ verify(exactly = 0) { PushNotificationEventManager.sendEvent(any(), any()) }
100
+ }
101
+
102
+ @Test
103
+ fun `onNewIntent sends notification opened event if intent contains payload`() {
104
+ module.onNewIntent(Intent())
105
+ verify {
106
+ PushNotificationEventManager.sendEvent(
107
+ PushNotificationEventType.NOTIFICATION_OPENED, mockMap
108
+ )
109
+ }
110
+ }
111
+
112
+ @Test
113
+ fun `only first onHostResume call is app launch`() {
114
+ module.onHostResume()
115
+ module.onHostResume()
116
+ verify(exactly = 1) {
117
+ PushNotificationEventManager.sendEvent(
118
+ PushNotificationEventType.TOKEN_RECEIVED, mockMap
119
+ )
120
+ PushNotificationEventManager.sendEvent(
121
+ PushNotificationEventType.LAUNCH_NOTIFICATION_OPENED, mockMap
122
+ )
123
+ }
124
+ }
125
+
126
+ @Test
127
+ fun `launch notification is set by app launch and consumed by getLaunchNotification call`() {
128
+ module.onHostResume()
129
+ module.getLaunchNotification(mockPromise)
130
+ module.getLaunchNotification(mockPromise)
131
+ verify(exactly = 1) {
132
+ mockPromise.resolve(mockMap)
133
+ mockPromise.resolve(null)
134
+ }
135
+ }
136
+
137
+ @Test
138
+ fun `launch notification is wiped by subsequent app launches`() {
139
+ module.onHostResume()
140
+ module.onHostResume()
141
+ module.getLaunchNotification(mockPromise)
142
+ verify { mockPromise.resolve(null) }
143
+ }
144
+
145
+ @Test
146
+ fun `returns ShouldRequest permission status`() {
147
+ module.getPermissionStatus(mockPromise)
148
+ verify { mockPromise.resolve(PushNotificationPermissionStatus.ShouldRequest.name) }
149
+ }
150
+
151
+ @Test
152
+ fun `returns ShouldExplainThenRequest permission status`() {
153
+ every { ActivityCompat.shouldShowRequestPermissionRationale(any(), any()) } returns true
154
+ module.getPermissionStatus(mockPromise)
155
+ verify { mockPromise.resolve(PushNotificationPermissionStatus.ShouldExplainThenRequest.name) }
156
+ }
157
+
158
+ @Test
159
+ fun `returns Granted permission status`() {
160
+ every { anyConstructed<PushNotificationPermission>().hasRequiredPermission } returns true
161
+ module.getPermissionStatus(mockPromise)
162
+ verify { mockPromise.resolve(PushNotificationPermissionStatus.Granted.name) }
163
+ }
164
+
165
+ @Test
166
+ fun `returns Denied permission status`() {
167
+ every { mockSharedPreferences.getBoolean(any(), any()) } returns true
168
+ module.getPermissionStatus(mockPromise)
169
+ verify { mockPromise.resolve(PushNotificationPermissionStatus.Denied.name) }
170
+ }
171
+
172
+ @Test
173
+ fun `requests permission`() = runTest {
174
+ val dispatcher = StandardTestDispatcher(testScheduler)
175
+ coEvery { anyConstructed<PushNotificationPermission>().requestPermission() } returns true
176
+ PushNotificationModule(mockContext, dispatcher).requestPermissions(mockk(), mockPromise)
177
+ advanceUntilIdle()
178
+ verify { mockPromise.resolve(true) }
179
+ }
180
+
181
+ @Test
182
+ fun `requests permission sets previously denied flag`() = runTest {
183
+ val dispatcher = StandardTestDispatcher(testScheduler)
184
+ val mockSharedPreferencesEditor = mockk<SharedPreferences.Editor>()
185
+ justRun { mockSharedPreferencesEditor.apply() }
186
+ every { ActivityCompat.shouldShowRequestPermissionRationale(any(), any()) } returns true
187
+ every { mockSharedPreferences.edit() } returns mockSharedPreferencesEditor
188
+ every {
189
+ mockSharedPreferencesEditor.putBoolean(
190
+ any(), any()
191
+ )
192
+ } returns mockSharedPreferencesEditor
193
+ coEvery { anyConstructed<PushNotificationPermission>().requestPermission() } returns false
194
+ PushNotificationModule(mockContext, dispatcher).requestPermissions(mockk(), mockPromise)
195
+ advanceUntilIdle()
196
+ verify {
197
+ mockPromise.resolve(false)
198
+ mockSharedPreferencesEditor.putBoolean("wasPermissionPreviouslyDenied", true)
199
+ }
200
+ }
201
+ }
@@ -0,0 +1,17 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ #ifndef AmplifyPushNotification_h
5
+ #define AmplifyPushNotification_h
6
+
7
+ #import <Foundation/Foundation.h>
8
+
9
+ @interface AmplifyPushNotification : NSObject
10
+
11
+ + (void) didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
12
+ + (void) didFailToRegisterForRemoteNotificationsWithError:(NSError*)error;
13
+ + (void) didReceiveRemoteNotification:(NSDictionary *)userInfo withCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler;
14
+
15
+ @end
16
+
17
+ #endif
@@ -0,0 +1,21 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ #import "AmplifyRTNPushNotification-Swift.h"
5
+ #import "AmplifyPushNotification.h"
6
+
7
+ @implementation AmplifyPushNotification
8
+
9
+ + (void) didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
10
+ [AmplifyPushNotificationAppDelegateHelper didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
11
+ }
12
+
13
+ + (void) didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {
14
+ [AmplifyPushNotificationAppDelegateHelper didFailToRegisterForRemoteNotificationsWithError:error];
15
+ }
16
+
17
+ + (void) didReceiveRemoteNotification:(NSDictionary*)userInfo withCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
18
+ [AmplifyPushNotificationAppDelegateHelper didReceiveRemoteNotificationWithUserInfo:userInfo completionHandler:completionHandler];
19
+ }
20
+
21
+ @end
@@ -0,0 +1,31 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import Foundation
5
+
6
+ @objc(AmplifyPushNotificationAppDelegateHelper)
7
+ public class AmplifyPushNotificationAppDelegateHelper: NSObject {
8
+ @objc
9
+ static public func didRegisterForRemoteNotificationsWithDeviceToken(_ deviceToken: Data) {
10
+ AmplifyRTNPushNotificationManager
11
+ .shared
12
+ .didRegisterForRemoteNotificationsWithDeviceToken(deviceToken: deviceToken)
13
+ }
14
+
15
+ @objc
16
+ static public func didFailToRegisterForRemoteNotificationsWithError(_ error: Error) {
17
+ AmplifyRTNPushNotificationManager
18
+ .shared
19
+ .didFailToRegisterForRemoteNotificationsWithError(error: error)
20
+ }
21
+
22
+ @objc
23
+ static public func didReceiveRemoteNotification(
24
+ userInfo: [AnyHashable: Any],
25
+ completionHandler: @escaping (UIBackgroundFetchResult) -> Void
26
+ ) {
27
+ AmplifyRTNPushNotificationManager
28
+ .shared
29
+ .didReceiveRemoteNotification(userInfo: userInfo, completionHandler: completionHandler)
30
+ }
31
+ }
@@ -0,0 +1,73 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import Foundation
5
+
6
+ enum NativeEvent {
7
+ case tokenReceived
8
+ case notificationOpened
9
+ case launchNotificationOpened
10
+ case backgroundMessageReceived
11
+ case foregroundMessageReceived
12
+
13
+ var key: String {
14
+ switch(self) {
15
+ case .tokenReceived:
16
+ return "TOKEN_RECEIVED"
17
+ case .notificationOpened:
18
+ return "NOTIFICATION_OPENED"
19
+ case .launchNotificationOpened:
20
+ return "LAUNCH_NOTIFICATION_OPENED"
21
+ case .backgroundMessageReceived:
22
+ return "BACKGROUND_MESSAGE_RECEIVED"
23
+ case .foregroundMessageReceived:
24
+ return "FOREGROUND_MESSAGE_RECEIVED"
25
+ }
26
+ }
27
+
28
+ var name: String {
29
+ switch(self) {
30
+ case .tokenReceived:
31
+ return "TokenReceived"
32
+ case .notificationOpened:
33
+ return "NotificationOpened"
34
+ case .launchNotificationOpened:
35
+ return "LaunchNotificationOpened"
36
+ case .foregroundMessageReceived:
37
+ return "ForegroundMessageReceived"
38
+ case .backgroundMessageReceived:
39
+ return "BackgroundMessageReceived"
40
+ }
41
+ }
42
+ }
43
+
44
+ struct AmplifyRTNEvent {
45
+ var type: NativeEvent
46
+ var payload: Any
47
+ }
48
+
49
+ class AmplifyRTNEventManager {
50
+ static let shared = AmplifyRTNEventManager()
51
+
52
+ private var eventQueue: [AmplifyRTNEvent] = []
53
+ private var sendEvent: ((AmplifyRTNEvent) -> Void)?
54
+
55
+ func setSendEvent(sendEvent: @escaping (AmplifyRTNEvent) -> Void) {
56
+ self.sendEvent = sendEvent
57
+ flushQueuedEvents();
58
+ }
59
+
60
+ func sendEventToJS(_ event: AmplifyRTNEvent) {
61
+ if let sendEvent = self.sendEvent {
62
+ sendEvent(event)
63
+ } else {
64
+ eventQueue.append(event)
65
+ }
66
+ }
67
+
68
+ private func flushQueuedEvents() {
69
+ while (!eventQueue.isEmpty) {
70
+ sendEventToJS(eventQueue.removeFirst())
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,7 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ #import <React/RCTBridgeModule.h>
5
+ #import <React/RCTViewManager.h>
6
+ #import <React/RCTEventEmitter.h>
7
+ #import <React/RCTRootView.h>
@@ -0,0 +1,26 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ #import <React/RCTEventEmitter.h>
5
+ #import <React/RCTBridgeModule.h>
6
+
7
+ @interface RCT_EXTERN_MODULE(AmplifyRTNPushNotification, RCTEventEmitter)
8
+
9
+ RCT_EXTERN_METHOD(requestPermissions:(NSDictionary*)permissions
10
+ resolve:(RCTPromiseResolveBlock)resolve
11
+ reject:(RCTPromiseRejectBlock)reject)
12
+
13
+ RCT_EXTERN_METHOD(getPermissionStatus:(RCTPromiseResolveBlock)resolve
14
+ reject:(RCTPromiseRejectBlock)reject)
15
+
16
+ RCT_EXTERN_METHOD(getLaunchNotification:(RCTPromiseResolveBlock)resolve
17
+ reject:(RCTPromiseRejectBlock)reject)
18
+
19
+ RCT_EXTERN_METHOD(setBadgeCount:(int)count)
20
+
21
+ RCT_EXTERN_METHOD(getBadgeCount:(RCTPromiseResolveBlock)resolve
22
+ reject:(RCTPromiseRejectBlock)reject)
23
+
24
+ RCT_EXTERN_METHOD(completeNotification:(NSString*)completionHandlerId)
25
+
26
+ @end
@@ -0,0 +1,121 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import Foundation
5
+
6
+ private let expectedEventNames: Set = [
7
+ NativeEvent.tokenReceived.name,
8
+ NativeEvent.backgroundMessageReceived.name,
9
+ NativeEvent.foregroundMessageReceived.name,
10
+ NativeEvent.notificationOpened.name,
11
+ NativeEvent.launchNotificationOpened.name
12
+ ]
13
+
14
+ @objc(AmplifyRTNPushNotification)
15
+ class AmplifyRTNPushNotification: RCTEventEmitter {
16
+
17
+ var registeredEventNames: Set<String> = []
18
+ var hasListeners = false
19
+ private let sharedNotificationManager: AmplifyRTNPushNotificationManager
20
+
21
+ // Override the bridge setter and getter to capture the launch options
22
+ override var bridge: RCTBridge! {
23
+ set(bridge) {
24
+ super.bridge = bridge
25
+
26
+ if let launchOptions = bridge.launchOptions {
27
+ sharedNotificationManager.handleLaunchOptions(launchOptions: launchOptions)
28
+ }
29
+ }
30
+ get {
31
+ return super.bridge
32
+ }
33
+ }
34
+
35
+ override init() {
36
+ sharedNotificationManager = AmplifyRTNPushNotificationManager.shared
37
+ super.init()
38
+ }
39
+
40
+ func notifyFlushQueuedEvents() {
41
+ AmplifyRTNEventManager.shared.setSendEvent(sendEvent: self.sendEventToJS)
42
+ }
43
+
44
+ func sendEventToJS(event: AmplifyRTNEvent) {
45
+ sendEvent(withName: event.type.name, body: event.payload)
46
+ }
47
+
48
+ override func addListener(_ eventName: String!) {
49
+ super.addListener(eventName)
50
+ registeredEventNames.insert(eventName)
51
+
52
+ if (registeredEventNames == expectedEventNames) {
53
+ notifyFlushQueuedEvents()
54
+ }
55
+ }
56
+
57
+ override func supportedEvents() -> [String]! {
58
+ return Array(expectedEventNames)
59
+ }
60
+
61
+ @objc
62
+ func requestPermissions(
63
+ _ permissions: [AnyHashable: Any],
64
+ resolve: @escaping RCTPromiseResolveBlock,
65
+ reject: @escaping RCTPromiseRejectBlock
66
+ ) {
67
+ sharedNotificationManager.requestPermissions(permissions, resolve: resolve, reject: reject)
68
+ }
69
+
70
+ @objc
71
+ func getPermissionStatus(
72
+ _ resolve: @escaping RCTPromiseResolveBlock,
73
+ reject: @escaping RCTPromiseRejectBlock
74
+ ) {
75
+ sharedNotificationManager.getPermissionStatus(resolve, reject: reject)
76
+ }
77
+
78
+ @objc
79
+ func getLaunchNotification(
80
+ _ resolve: RCTPromiseResolveBlock,
81
+ reject: RCTPromiseRejectBlock
82
+ ) {
83
+ sharedNotificationManager.getLaunchNotification(resolve, reject: reject)
84
+ }
85
+
86
+ @objc
87
+ func setBadgeCount(_ count: Int) {
88
+ sharedNotificationManager.setBadgeCount(count)
89
+ }
90
+
91
+ @objc
92
+ func getBadgeCount(
93
+ _ resolve: @escaping RCTPromiseResolveBlock,
94
+ reject: RCTPromiseRejectBlock
95
+ ) {
96
+ sharedNotificationManager.getBadgeCount(resolve, reject: reject)
97
+ }
98
+
99
+ @objc
100
+ func completeNotification(_ completionHandlerId: String) {
101
+ sharedNotificationManager.completeNotification(completionHandlerId)
102
+ }
103
+
104
+ @objc
105
+ override static func requiresMainQueueSetup() -> Bool {
106
+ return true
107
+ }
108
+
109
+ @objc
110
+ override func constantsToExport() -> [AnyHashable : Any]! {
111
+ return [
112
+ "NativeEvent": [
113
+ NativeEvent.backgroundMessageReceived.key: NativeEvent.backgroundMessageReceived.name,
114
+ NativeEvent.foregroundMessageReceived.key: NativeEvent.foregroundMessageReceived.name,
115
+ NativeEvent.notificationOpened.key: NativeEvent.notificationOpened.name,
116
+ NativeEvent.launchNotificationOpened.key: NativeEvent.launchNotificationOpened.name,
117
+ NativeEvent.tokenReceived.key: NativeEvent.tokenReceived.name,
118
+ ],
119
+ ]
120
+ }
121
+ }
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "group:AmplifyPushNotification.h">
6
+ </FileRef>
7
+ <FileRef
8
+ location = "group:AmplifyPushNotification.m">
9
+ </FileRef>
10
+ <FileRef
11
+ location = "group:AmplifyPushNotificationAppDelegateHelper.swift">
12
+ </FileRef>
13
+ <FileRef
14
+ location = "group:AmplifyRTNEventManager.swift">
15
+ </FileRef>
16
+ <FileRef
17
+ location = "group:AmplifyRTNPushNotification-Bridging-Header.h">
18
+ </FileRef>
19
+ <FileRef
20
+ location = "group:AmplifyRTNPushNotification.m">
21
+ </FileRef>
22
+ <FileRef
23
+ location = "group:AmplifyRTNPushNotification.swift">
24
+ </FileRef>
25
+ <FileRef
26
+ location = "group:AmplifyRTNPushNotificationManager.swift">
27
+ </FileRef>
28
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>