Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IAM Preview Notification being handle as normal Notification #1376

Merged
merged 6 commits into from
Jul 9, 2021

Conversation

Jeasmine
Copy link
Contributor

@Jeasmine Jeasmine commented Jul 6, 2021

### Bug
IAM Notification was being handled as a normal notification; this means that notifications callbacks from the user were being called and receive receipt request was also made for this notification.

### Solution
Currently, we have IAM handling, but only if the app is in the foreground. Add Notification display to the same inAppMessagePreviewHandled method. This helped cleaning some code, checking if IAM is preview inside common notification display flow was removed.

Review commit by commit to seeing the process of fixing


This change is Reviewable

* Move inAppMessagePreviewHandled and inAppPreviewPushUUID method from NotificationBundleProcessor to OSInAppMessagePreviewHandler
* OSNotificationGenerationJob won't handle IAM state
* Encapsulate ProcessedBundleResult fields
* Handle IAM logic inside OSInAppMessagePreviewHandler
* Display Notification if IAM Preview and app not in foreground
* Remove Worker handling from IAM Preview since there is no images or DB logic needed
@Jeasmine Jeasmine requested a review from jkasten2 July 6, 2021 18:13
…7 test

* Test was failing due to SDK version check; this check was only applying to IAMs notifications. Move the check to inAppMessagePreviewHandled
@Jeasmine Jeasmine requested a review from emawby July 8, 2021 19:06
Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice overall cleanup. A few optional comments.

Reviewed 7 of 7 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @emawby and @Jeasmine)


OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessagePreviewHandler.java, line 15 at r1 (raw file):

import static com.onesignal.NotificationBundleProcessor.PUSH_ADDITIONAL_DATA_KEY;

class OSInAppMessagePreviewHandler {

Since this is a new class what do you think about using Kotlin instead?


OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessagePreviewHandler.java, line 21 at r1 (raw file):

        // Show In-App message preview it is in the payload & the app is in focus
        String previewUUID = inAppPreviewPushUUID(pushPayloadJson);
        if (previewUUID != null) {

Would be a bit easier to read if this was an early return instead.

 if (previewUUID == null) {
    return false;
}

@emawby emawby requested a review from nan-li July 9, 2021 17:04
Copy link
Contributor

@emawby emawby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7 of 7 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Jeasmine and @nan-li)

* Refactor from Java to Kotlin
Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Jeasmine and @nan-li)

@Jeasmine Jeasmine merged commit 20c7f2a into main Jul 9, 2021
@Jeasmine Jeasmine deleted the fix/iam-preview-receive-receipt branch July 9, 2021 22:34
@Jeasmine Jeasmine mentioned this pull request Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants