Skip to content

Commit c484cf6

Browse files
authored
Fix possible crash in Rich Interstitial (#468)
* Fix possible crash in Rich Interstitial * Log messageId on crash
1 parent ecda0c5 commit c484cf6

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

AndroidSDKCore/src/main/java/com/leanplum/messagetemplates/controllers/RichHtmlController.java

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import androidx.annotation.NonNull;
4444
import com.leanplum.ActionContext;
4545
import com.leanplum.Leanplum;
46+
import com.leanplum.internal.Log;
4647
import com.leanplum.messagetemplates.DialogCustomizer;
4748
import com.leanplum.messagetemplates.MessageTemplates;
4849
import com.leanplum.messagetemplates.options.RichHtmlOptions;
@@ -210,27 +211,36 @@ private WebView createHtml(Context context) {
210211
@SuppressWarnings("deprecation")
211212
@Override
212213
public boolean shouldOverrideUrlLoading(WebView wView, String url) {
213-
if (isClosing) // prevent multiple clicks on same button
214-
return true;
215-
216-
// Open URL event.
217-
if (handleOpenEvent(url)){
218-
return true;
219-
}
220-
221-
// Close URL event.
222-
if (handleCloseEvent(url)) {
223-
return true;
224-
}
225-
226-
// Track URL event.
227-
if (handleTrackEvent(url)) {
228-
return true;
229-
}
230-
231-
// Action URL or track action URL event.
232-
if (handleActionEvent(url)) {
233-
return true;
214+
try {
215+
if (isClosing) // prevent multiple clicks on same button
216+
return true;
217+
218+
// Open URL event.
219+
if (handleOpenEvent(url)) {
220+
return true;
221+
}
222+
223+
// Close URL event.
224+
if (handleCloseEvent(url)) {
225+
return true;
226+
}
227+
228+
// Track URL event.
229+
if (handleTrackEvent(url)) {
230+
return true;
231+
}
232+
233+
// Action URL or track action URL event.
234+
if (handleActionEvent(url)) {
235+
return true;
236+
}
237+
} catch (Throwable t) {
238+
String messageId = "";
239+
ActionContext actionContext = richOptions.getActionContext();
240+
if (actionContext != null) {
241+
messageId = actionContext.getMessageId();
242+
}
243+
Log.e("Error in Rich Interstitial messageId=" + messageId, t);
234244
}
235245

236246
return false;

0 commit comments

Comments
 (0)