OneSignal-Android-SDK icon indicating copy to clipboard operation
OneSignal-Android-SDK copied to clipboard

CRASH - When the launch url is invalide

Open MichaelOliveiraBx opened this issue 2 years ago • 4 comments

Description

Catch an crash when the url is invalide and add an callback in case of this error happen

Details

Motivation

FIX this issue

Scope

When we start the destination activity more than JSONException we catch ActivityNotFoundException and we call the listener

Manual testing

Tested opening a notification with an invalide url , app build with Android Studio 2023.1.1 with our app (Omada) on a Pixel 5 with Android 13.

Affected code checklist

  • [x] Notifications
    • [ ] Display
    • [x] Open
    • [ ] Push Processing
    • [ ] Confirm Deliveries
  • [ ] Outcomes
  • [ ] Sessions
  • [ ] In-App Messaging
  • [ ] REST API requests
  • [ ] Public API changes

Checklist

Overview

  • [x] I have filled out all REQUIRED sections above
  • [x] PR does one thing
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • [x] Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • [x] I have included test coverage for these changes, or explained why they are not needed
  • [x] All automated tests pass, or I explained why that is not possible
  • [x] I have personally tested this on my device, or explained why that is not possible

Final pass

  • [x] Code is as readable as possible.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • [x] I have reviewed this PR myself, ensuring it meets each checklist item
    • WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.

This change is Reviewable

MichaelOliveiraBx avatar Jan 05 '24 13:01 MichaelOliveiraBx

My bad I forget to add the setter for the listener, I have add it on the next commit. I will squash after your review.

MichaelOliveiraBx avatar Jan 11 '24 13:01 MichaelOliveiraBx

@MichaelOliveiraBx Thank you for reporting this and uploading your work! We are currently reviewing this issue. Out of curiosity, what plans do you have in mind for handling the event when an ActivityNotFoundException is thrown?

jinliu9508 avatar Jan 11 '24 22:01 jinliu9508

Your welcome! To be honest, log the stack trace of the exception will be enough for me. But I tell that this is an information that we might want to know because it is linked to a setup problem. And so we may want to put an alert when the person has set up a bad URL on the BO. But if you think it is too much, I can remove it easily

MichaelOliveiraBx avatar Jan 16 '24 10:01 MichaelOliveiraBx

Hi @MichaelOliveiraBx, thanks again for your PR.

An error-level log would be ideal, so we don't introduce another interface, since we don't have callbacks for other type of errors.

nan-li avatar Jan 30 '24 20:01 nan-li