Skip to content

Commit a70c63c

Browse files
authored
Merge branch 'main' into onboard-npm-trusted-publishing
2 parents dd59c41 + a93c38c commit a70c63c

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

packages/rtn-push-notification/android/src/main/kotlin/com/amazonaws/amplify/rtnpushnotification/PushNotificationModule.kt

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class PushNotificationModule(
116116
"NativeHeadlessTaskKey" to PushNotificationHeadlessTaskService.HEADLESS_TASK_KEY
117117
)
118118

119-
override fun onActivityResult(p0: Activity?, p1: Int, p2: Int, p3: Intent?) {
119+
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
120120
// noop - only overridden as this class implements ActivityEventListener
121121
}
122122

@@ -157,15 +157,19 @@ class PushNotificationModule(
157157
params
158158
)
159159
})
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+
}
169173
}
170174
}
171175
} else {
@@ -183,6 +187,7 @@ class PushNotificationModule(
183187
}
184188

185189
private fun shouldShowRequestPermissionRationale(): Boolean {
186-
return ActivityCompat.shouldShowRequestPermissionRationale(currentActivity!!, PERMISSION)
190+
val activity = reactApplicationContext.getCurrentActivity() ?: return false
191+
return ActivityCompat.shouldShowRequestPermissionRationale(activity, PERMISSION)
187192
}
188-
}
193+
}

0 commit comments

Comments
 (0)