|
13 | 13 | // limitations under the License.
|
14 | 14 | package com.google.firebase.messaging;
|
15 | 15 |
|
| 16 | +import static com.google.firebase.messaging.Constants.TAG; |
| 17 | + |
16 | 18 | import android.app.Activity;
|
17 | 19 | import android.app.Application;
|
18 | 20 | import android.content.Intent;
|
|
21 | 23 | import android.os.Bundle;
|
22 | 24 | import android.os.Handler;
|
23 | 25 | import android.os.Looper;
|
| 26 | +import android.util.Log; |
24 | 27 | import java.util.Collections;
|
25 | 28 | import java.util.Set;
|
26 | 29 | import java.util.WeakHashMap;
|
@@ -74,12 +77,19 @@ public void onActivityResumed(Activity activity) {}
|
74 | 77 | public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {}
|
75 | 78 |
|
76 | 79 | private void logNotificationOpen(Intent startingIntent) {
|
77 |
| - Bundle extras = startingIntent.getExtras(); |
78 |
| - if (extras != null) { |
79 |
| - Bundle analyticsData = extras.getBundle(Constants.MessageNotificationKeys.ANALYTICS_DATA); |
80 |
| - if (MessagingAnalytics.shouldUploadScionMetrics(analyticsData)) { |
81 |
| - MessagingAnalytics.logNotificationOpen(analyticsData); |
| 80 | + Bundle analyticsData = null; |
| 81 | + try { |
| 82 | + Bundle extras = startingIntent.getExtras(); |
| 83 | + if (extras != null) { |
| 84 | + analyticsData = extras.getBundle(Constants.MessageNotificationKeys.ANALYTICS_DATA); |
82 | 85 | }
|
| 86 | + } catch (RuntimeException e) { |
| 87 | + // Don't crash if there was a problem trying to get the analytics data Bundle since the |
| 88 | + // Intent could be coming from anywhere and could be incorrectly formatted. |
| 89 | + Log.w(TAG, "Failed trying to get analytics data from Intent extras.", e); |
| 90 | + } |
| 91 | + if (MessagingAnalytics.shouldUploadScionMetrics(analyticsData)) { |
| 92 | + MessagingAnalytics.logNotificationOpen(analyticsData); |
83 | 93 | }
|
84 | 94 | }
|
85 | 95 | }
|
0 commit comments