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

Make OneSignalId and ExternalId nullable for Android #699

Merged
merged 3 commits into from
Feb 22, 2024

Conversation

jinliu9508
Copy link
Contributor

@jinliu9508 jinliu9508 commented Feb 21, 2024

Description

One Line Summary

Make OneSignalId and ExternalId nullable for Android. The result of calling the getter will be null if no ID is currently available.

Details

Motivation

To keep all wrappers consistent when dealing with the IDs.

Testing

Manual testing

I have modified the example scene so that it displays "null" if calling the ID getter results in a null string. Tested on Android emulator pixel 3a API 34

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • 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
    • If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
  • 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.
    • Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
  • I have reviewed this PR myself, ensuring it meets each checklist item
    • WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.

This change is Reviewable

Copy link
Contributor

@shepherd-l shepherd-l left a comment

Choose a reason for hiding this comment

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

Lgtm!

I think the editor platform methods could also return null because the subscription doesn't get created on the backend. What do you think? Do you have an preferences?
https://github.com/OneSignal/OneSignal-Unity-SDK/blob/user-model/main/com.onesignal.unity.core/Editor/Platform/UserManager.cs#L35

@nan-li nan-li self-requested a review February 21, 2024 23:15
Copy link

@nan-li nan-li left a comment

Choose a reason for hiding this comment

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

Is this also addressed for the UserState object? {"onesignalId": "123456789, "externalId": null}

@jinliu9508
Copy link
Contributor Author

Lgtm!

I think the editor platform methods could also return null because the subscription doesn't get created on the backend. What do you think? Do you have an preferences? https://github.com/OneSignal/OneSignal-Unity-SDK/blob/user-model/main/com.onesignal.unity.core/Editor/Platform/UserManager.cs#L35

Ok I just made that change. I think it will keep the code consistent regarding the default value of the IDs.

@jinliu9508
Copy link
Contributor Author

Is this also addressed for the UserState object? {"onesignalId": "123456789, "externalId": null}

Yes, both null and "" will make the getter to return null.

@nan-li
Copy link

nan-li commented Feb 22, 2024

Is this also addressed for the UserState object? {"onesignalId": "123456789, "externalId": null}

Yes, both null and "" will make the getter to return null.

For the UserState that is passed to observers? I am not sure how everything is translated across Unity bridges, but here it uses the jsonRepresentation method which returns empty strings. Does it later translate to null in another layer?

@jinliu9508
Copy link
Contributor Author

Is this also addressed for the UserState object? {"onesignalId": "123456789, "externalId": null}

Yes, both null and "" will make the getter to return null.

For the UserState that is passed to observers? I am not sure how everything is translated across Unity bridges, but here it uses the jsonRepresentation method which returns empty strings. Does it later translate to null in another layer?

Unity string is nullable and yes this line of code string.IsNullOrEmpty(id)? null : id; later translate the string to null for either empty or null string from the native.

@nan-li nan-li self-requested a review February 22, 2024 18:47
@nan-li
Copy link

nan-li commented Feb 22, 2024

Unity string is nullable and yes this line of code string.IsNullOrEmpty(id)? null : id; later translate the string to null for either empty or null string from the native.

Ok! 👍🏼 Thanks! I did not know that also applied to the UserState

@jinliu9508 jinliu9508 merged commit 317576d into user-model/main Feb 22, 2024
1 check passed
@jinliu9508 jinliu9508 deleted the make-get-ids-nullable branch February 22, 2024 19:22
jinliu9508 added a commit that referenced this pull request Feb 23, 2024
Make OneSignalId and ExternalId nullable for Android
jinliu9508 added a commit that referenced this pull request Feb 27, 2024
Make OneSignalId and ExternalId nullable for Android
jinliu9508 added a commit that referenced this pull request Feb 27, 2024
Make OneSignalId and ExternalId nullable for Android
jinliu9508 added a commit that referenced this pull request Feb 27, 2024
Make OneSignalId and ExternalId nullable for Android
jinliu9508 added a commit that referenced this pull request Feb 27, 2024
Make OneSignalId and ExternalId nullable for Android
jinliu9508 added a commit that referenced this pull request Mar 1, 2024
Make OneSignalId and ExternalId nullable for Android
jinliu9508 added a commit that referenced this pull request Mar 4, 2024
Make OneSignalId and ExternalId nullable for Android
jinliu9508 added a commit that referenced this pull request Mar 4, 2024
Make OneSignalId and ExternalId nullable for Android
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.

None yet

4 participants