@aws-amplify/rtn-push-notification 1.3.0 → 1.3.1-context-cogs.077566e.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.
@@ -116,7 +116,7 @@ class PushNotificationModule(
116
116
  "NativeHeadlessTaskKey" to PushNotificationHeadlessTaskService.HEADLESS_TASK_KEY
117
117
  )
118
118
 
119
- override fun onActivityResult(p0: Activity?, p1: Int, p2: Int, p3: Intent?) {
119
+ override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
120
120
  // noop - only overridden as this class implements ActivityEventListener
121
121
  }
122
122
 
@@ -157,15 +157,19 @@ class PushNotificationModule(
157
157
  params
158
158
  )
159
159
  })
160
- currentActivity?.intent?.let {
161
- val payload = NotificationPayload.fromIntent(it)
162
- if (payload != null) {
163
- launchNotification = payload.toWritableMap()
164
- // Launch notification opened event is emitted for internal use only
165
- PushNotificationEventManager.sendEvent(
166
- PushNotificationEventType.LAUNCH_NOTIFICATION_OPENED,
167
- payload.toWritableMap()
168
- )
160
+ val activity = reactApplicationContext.getCurrentActivity()
161
+ if (activity != null) {
162
+ val activityIntent = activity.intent
163
+ if (activityIntent != null) {
164
+ val payload = NotificationPayload.fromIntent(activityIntent)
165
+ if (payload != null) {
166
+ launchNotification = payload.toWritableMap()
167
+ // Launch notification opened event is emitted for internal use only
168
+ PushNotificationEventManager.sendEvent(
169
+ PushNotificationEventType.LAUNCH_NOTIFICATION_OPENED,
170
+ payload.toWritableMap()
171
+ )
172
+ }
169
173
  }
170
174
  }
171
175
  } else {
@@ -183,6 +187,7 @@ class PushNotificationModule(
183
187
  }
184
188
 
185
189
  private fun shouldShowRequestPermissionRationale(): Boolean {
186
- return ActivityCompat.shouldShowRequestPermissionRationale(currentActivity!!, PERMISSION)
190
+ val activity = reactApplicationContext.getCurrentActivity() ?: return false
191
+ return ActivityCompat.shouldShowRequestPermissionRationale(activity, PERMISSION)
187
192
  }
188
- }
193
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/rtn-push-notification",
3
- "version": "1.3.0",
3
+ "version": "1.3.1-context-cogs.077566e.0+077566e",
4
4
  "description": "React Native module for aws-amplify push notifications",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.mjs",
@@ -53,5 +53,5 @@
53
53
  "dist/esm",
54
54
  "src"
55
55
  ],
56
- "gitHead": "2ffc7200d2e7ca45b51bf40316431cf467065c32"
56
+ "gitHead": "077566e885ed4bd8cc94a6e7ef7f3eda96ec161a"
57
57
  }