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] notification permission prompt callback firing when app is foregrounded #1615

Merged

Conversation

jkasten2
Copy link
Member

@jkasten2 jkasten2 commented Jul 19, 2022

Details

One Line Summary

Fixes a bug where OneSignal.promptForPushNotifications would fire before the user answers the prompt if the app was background and then foregrounded when showing.

Motivation

The bug also happens even if the app is not backgrounded on some of the OneSignal wrapper / binder SDKs due their initialization flows.

Scope

Only effects notification permission prompting on Android 13. This fixes a bug were this feature was first introduced in #1607.

Testing

Unit testing

No existing tests.

Manual testing

Tested on an Android 13 Beta 3 emulator. Ensured I could reproduce the issue before the fix by backgrounding the app then foregrounding it. Also ensured the callback still fires when it should when returning from the system notification permission screen.

Affected code checklist

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

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

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

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

This change is Reviewable

Fix bug where the callback passed to promptForPushNotifications would
fire false if there was a foreground event being processes by the SDK.
This would happen in the following case:
1. if you prompted but the user backgrounded and foregrounded the app
before answering the prompt.
2. If promptForPushNotifications was called before the SDK detected the
app was foregrounded.
@jkasten2 jkasten2 merged commit 6ab28a9 into main Jul 20, 2022
@jkasten2 jkasten2 deleted the fix/notification_prompt_callback_firing_on_foregrounding branch July 20, 2022 05:25
@jkasten2 jkasten2 mentioned this pull request Jul 20, 2022
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.

4 participants