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

Add getters and observer for onesignal ID and external ID #1344

Merged
merged 8 commits into from
Dec 15, 2023

Commits on Dec 5, 2023

  1. Use another class to be push subscription namespace

    Background:
    The User Manager is itself the user namespace AND the push subscription namespace via implementing both protocols. The problem is that we will be adding an `addObserver` method to the User namespace and this will conflict with the existing `addObserver` method that exists on the Push Subscription namespace.
    
    Solution:
    Use a separate class `OSPushSubscriptionImpl` that will implement the push subscription namespace. And an instance of this class will live on the User Manager.
    Also update existing code to go through pushSubscriptionImpl.
    nan-li committed Dec 5, 2023
    Configuration menu
    Copy the full SHA
    9c4a05f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    03d09f0 View commit details
    Browse the repository at this point in the history
  3. Add user state observer

    Problem:
    App developers want to know the onesignal ID for a user, but it can be null if we have not received the response from the server after a fresh install or after logging in.
    
    Solution:
    Offer a user state observer that will fire when the response is received and fire with the onesignal ID and external ID.
    
    Implementation Details:
    On Identity Model hydration from the server (when onesignal_id is received), we will snapshot the onesignal_id and external_id as the conclusive IDs for the current user. On future hydrations after logging in, we will compare to the previous snapshot to know if the observer should be fired.
    
    We must not only compare onesignal_id but also external_id for the case of logging in Anonymous -> New Identified. In this case, the onesignal_id will not change but the external_id will be attached to the user on the server.
    nan-li committed Dec 5, 2023
    Configuration menu
    Copy the full SHA
    920662c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e2c5323 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    dd8f47b View commit details
    Browse the repository at this point in the history
  6. Json representation of User State uses empty string, not "nil"

    When giving a jsonRepresentation of OSUserState, choose empty string as the representation of a null value instead of the string literal "nil". The string "nil" can be interpreted as an existing value whereas the empty string is a better option as it can be checked for `isEmpty`.
    nan-li committed Dec 5, 2023
    Configuration menu
    Copy the full SHA
    d3bae81 View commit details
    Browse the repository at this point in the history

Commits on Dec 6, 2023

  1. Remove previous from user state changed

    * We are removing the previous user state from the public user state changed state. We will consider adding this in the future.
    nan-li committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    813933c View commit details
    Browse the repository at this point in the history

Commits on Dec 11, 2023

  1. Add in-code documentation on user state observer

    * Add a callout on the usage of the user state observer.
    * App developers should be checking the `externalId` when they retreive the `onesignalId`. This is to make sure they are grabbing the onesignalId for the user that they expect.
    nan-li committed Dec 11, 2023
    Configuration menu
    Copy the full SHA
    06ab04a View commit details
    Browse the repository at this point in the history