Skip to content

[Bug]: optedIn is not being updated accordingly on Android #1043

Description

@luanalbineli

What happened?

We have a screen where the user can opt in/out to push notifications. To get the current opt value, we use the following code (assuming that notification permissions are granted):

OneSignal.User.pushSubscription.optedIn

To opt in/out, we are using the following code (depending on user's choice):

// Opt out.
await OneSignal.User.pushSubscription.optOut();

// Opt in.
await OneSignal.User.pushSubscription.optIn();

After we close/open the app, or sometimes after a Hot Restart, the optedIn property no longer gets updated properly, after the opt in/out call.

On the background, the operation is enqueued and executed properly:

[main] OperationRepo.enqueue(operation: {"name":"update-subscription","appId":"APP_ID","onesignalId":
"ONE_SIGNAL_ID","subscriptionId":"SUB_ID","type":"PUSH","enabled":true,"address":"ADDRESS",
"status":"SUBSCRIBED"}, flush: false)

[DefaultDispatcher-worker-8] HttpClient: Request Sent = PATCH https://api.onesignal.com/apps/{APP_ID}/subscriptions/{SUB_ID}
Body: {"subscription":{"type":"AndroidPush","token":"TOKEN","enabled":true...}

On the example above, I've tried to opt in. I called await OneSignal.User.pushSubscription.optIn();, closed the screen, opened again, and the optedIn was still false.

I'm currently running the tests on a Physical Android device (Samsung S21 Ultra).

Steps to reproduce?

1. Install version 5.3.0.
2. Android user opens the app (with notification permissions granted).
3. User opt out from notifications.
4. User restarts the app.
4. User opt in.

What did you expect to happen?

OneSignal.User.pushSubscription.optedIn should be true. Instead is false.

OneSignal Flutter SDK version

5.3.0

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions