Skip to content

[Bug]: optIn() and optOut() seem like they should return a promise that one can await #967

@kpturner

Description

@kpturner

What happened?

Both the optIn and optOpt methods do not return anything and do not appear to be async. However, surely under the covers both are making an async communication with the OneSignal backend? This being so, it is not possible to await the outcome. It is possible to do lots of optIn and optOut calls in a client app and not really know what the final outcome is, because there is no guarantee that the updates to the backend will be processed in the order that you executed them. For example, I could call optIn and optOut one after the other but the optIn request might be processed after the optOut. So the app thinks it is opted out when in fact it is not.

This is the only explanation I can think of for the situation we have where the "opted in" status in OneSignal does not always match the last status update the app thinks it sent.

Why can we not await each of these calls so that we know that it has been received and processed?

Steps to reproduce?

Described above

What did you expect to happen?

I would expect all methods that perform async requests to the OneSignal backend to return a promise that can be awaited.

OneSignal Cordova SDK version

5.0.4

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions