From 14bdca2c8e699251d317a92d36adff1cb5e43974 Mon Sep 17 00:00:00 2001 From: Thomas Leing Date: Fri, 20 Jan 2023 15:42:38 -0800 Subject: [PATCH] If event collection is disabled, opening a notification will also cause a crash --- .../notification/NotificationClientBase.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/aws-android-sdk-pinpoint/src/main/java/com/amazonaws/mobileconnectors/pinpoint/targeting/notification/NotificationClientBase.java b/aws-android-sdk-pinpoint/src/main/java/com/amazonaws/mobileconnectors/pinpoint/targeting/notification/NotificationClientBase.java index e0f574ca43..ba0e13cbf2 100644 --- a/aws-android-sdk-pinpoint/src/main/java/com/amazonaws/mobileconnectors/pinpoint/targeting/notification/NotificationClientBase.java +++ b/aws-android-sdk-pinpoint/src/main/java/com/amazonaws/mobileconnectors/pinpoint/targeting/notification/NotificationClientBase.java @@ -844,12 +844,15 @@ NotificationClient.PushResult handleNotificationOpen( if (this.pinpointContext.getSessionClient() != null) { this.pinpointContext.getSessionClient().stopSession(); } - this.pinpointContext.getAnalyticsClient().updateEventSourceGlobally(eventSourceAttributes); - String eventType = eventSourceType.getEventTypeOpenend(); - final AnalyticsEvent pushEvent = this.pinpointContext.getAnalyticsClient().createEvent(eventType); - this.pinpointContext.getAnalyticsClient().recordEvent(pushEvent); - this.pinpointContext.getAnalyticsClient().submitEvents(); + if (this.pinpointContext.getAnalyticsClient() != null) { + this.pinpointContext.getAnalyticsClient().updateEventSourceGlobally(eventSourceAttributes); + + String eventType = eventSourceType.getEventTypeOpenend(); + final AnalyticsEvent pushEvent = this.pinpointContext.getAnalyticsClient().createEvent(eventType); + this.pinpointContext.getAnalyticsClient().recordEvent(pushEvent); + this.pinpointContext.getAnalyticsClient().submitEvents(); + } final String url = data.getString(EVENT_SOURCE_URL_PUSH_KEY); if (url != null) {