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

[User Model] Fixes #626

Merged
merged 18 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions MIGRATION_GUIDE_v3_to_v5.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Unity v5.0.0-beta.3 Migration Guide
# Unity v5.0.0 Migration Guide
In this release, we are making a significant shift from a device-centered model to a user-centered model. A user-centered model allows for more powerful omni-channel integrations within the OneSignal platform.

This migration guide will walk you through the Unity SDK v5.0.0 changes as a result of this shift.
Expand Down Expand Up @@ -83,6 +83,8 @@ Initialization of the OneSignal SDK, although similar to past versions, has chan
// We recommend removing the following code and instead using an In-App Message to prompt for notification permission.
var result = await OneSignal.Notifications.RequestPermissionAsync(true);

_For iOS: Remove any usages of `setLaunchURLsInApp` as the method and functionality has been removed._

If your integration is not user-centric, there is no additional startup code required. A user is automatically created as part of the push subscription creation, both of which are only accessible from the current device and the OneSignal dashboard.

If your integration is user-centric, or you want the ability to identify as the same user on multiple devices, the OneSignal SDK should be called once the user has been identified:
Expand Down Expand Up @@ -147,7 +149,6 @@ The SDK is still accessible via a `OneSignal` static class, it provides access t
| `void Initialize(string appId)` | *Initialize the OneSignal SDK. This should be called during startup of the application.* |
| `void Login(string externalId, string jwtBearerToken = null)` | *Login to OneSignal under the user identified by the [externalId] provided. The act of logging a user into the OneSignal SDK will switch the [user] context to that specific user.*<br><br>- *If the [externalId] exists the user will be retrieved and the context set from that user information. If operations have already been performed under a guest user, they* ***will not*** *be applied to the now logged in user (they will be lost).*<br>- *If the [externalId] does not exist the user will be created and the context set from the current local state. If operations have already been performed under a guest user those operations* ***will*** *be applied to the newly created user.*<br><br>***Push Notifications and In App Messaging***<br>*Logging in a new user will automatically transfer push notification and in app messaging subscriptions from the current user (if there is one) to the newly logged in user. This is because both Push and IAM are owned by the device.* |
| `void Logout()` | *Logout the user previously logged in via [login]. The [user] property now references a new device-scoped user. A device-scoped user has no user identity that can later be retrieved, except through this device as long as the app remains installed and the app data is not cleared.* |
| `void SetLaunchURLsInApp(bool launchInApp)` | ***Note:*** *This method is for iOS only<br>This method can be used to set if launch URLs should be opened in Safari or within the application. Set to true to launch all notifications with a URL in the app instead of the default web browser. Make sure to call SetLaunchURLsInApp before the initialize call.* |

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets also call out this removal somewhere in the guide. In the iOS guide I said this in the initialization section

Remove any usages of setLaunchURLsInApp as the method and functionality has been removed.


**User Namespace**
Expand Down Expand Up @@ -203,7 +204,7 @@ The location namespace is accessible via `OneSignal.Location` and provides acces
| **C#** | **Description** |
| ---------------------------| -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bool IsShared` | *Whether location is currently shared with OneSignal.* |
| `Task<bool> RequestPermissionAsync()` | *Use this method to manually prompt the user for location permissions. This allows for geotagging so you send notifications to users based on location.* |
| `void RequestPermission()` | *Use this method to manually prompt the user for location permissions. This allows for geotagging so you send notifications to users based on location.* |


**InAppMessages Namespace**
Expand Down Expand Up @@ -240,12 +241,13 @@ The debug namespace is accessible via `OneSignal.Debug` and provides access to d


# Limitations
- Recommend using only in development and staging environments for Beta releases.
- Outcomes will be available in a future release
- Changing app IDs is not supported.
- Any User namespace calls must be invoked after initialization. Example: OneSignal.User.AddTag("tag", "2")
- In the SDK, the user state is only refreshed from the server when a new session is started (cold start or backgrounded for over 30 seconds) or when the user is logged in. This is by design.

# Known issues
- Identity Verification
- We will be introducing JWT in follow up Beta release
- We will be introducing JWT in a follow up release

# Troubleshooting

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 10 additions & 0 deletions OneSignalExample/Assets/OneSignal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Removed `SetLaunchURLsInApp`
- Removed async from location request permission and updated method name to `RequestPermission`
- Updated included iOS SDK to [5.0.1](https://github.com/OneSignal/OneSignal-iOS-SDK/releases/tag/5.0.1)
- Updated included Android SDK to [5.0.0](https://github.com/OneSignal/OneSignal-Android-SDK/releases/tag/5.0.0)
- Updated default OneSignal Android notificaiton icons to new logo
### Fixed
- Outcome method calls on Android
- Completion check for the Copy Android plugin to Assets setup step

## [5.0.0-beta.3]
### Changed
- Updated `Notifications`, `InAppMessages`, and `User` models to have Pascal Case properties
Expand Down
2 changes: 1 addition & 1 deletion OneSignalExample/Assets/OneSignal/Editor/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Modified MIT License
*
* Copyright 2022 OneSignal
* Copyright 2023 OneSignal
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -59,7 +59,7 @@ public class OneSignalExampleBehaviour : MonoBehaviour {
public string phoneNumber;

/// <summary>
/// set to your app id (https://documentation.onesignal.com/docs/accounts-and-keys)
/// set to your app id (https://documentation.onesignal.com/docs/keys-and-ids)
/// </summary>
public string appId;

Expand All @@ -74,11 +74,6 @@ public class OneSignalExampleBehaviour : MonoBehaviour {
/// </summary>
public bool consentGiven;

/// <summary>
/// used to set if launch URLs should be opened in safari or within the application
/// </summary>
public bool launchURLsInApp;

/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -140,7 +135,7 @@ public class OneSignalExampleBehaviour : MonoBehaviour {
/// </summary>
private void Start() {
// Enable lines below to debug issues with OneSignal
OneSignal.Debug.LogLevel = LogLevel.Info;
OneSignal.Debug.LogLevel = LogLevel.Verbose;
OneSignal.Debug.AlertLevel = LogLevel.Fatal;

_log($"Initializing with appId <b>{appId}</b>");
Expand Down Expand Up @@ -401,15 +396,9 @@ public void AddOutcomeWithValue() {
* Location
*/

public async void PromptLocation() {
_log("Opening permission prompt for location and awaiting result...");

var result = await OneSignal.Location.RequestPermissionAsync();

if (result)
_log("Location permission accepeted");
else
_log("Location permission denied");
public void PromptLocation() {
_log("Opening permission prompt for location");
OneSignal.Location.RequestPermission();
}

public void ToggleShareLocation() {
Expand All @@ -421,13 +410,6 @@ public void ToggleShareLocation() {
* iOS
*/

public void ToggleLaunchURLsInApp() {
_log($"Toggling LaunchURLsInApp to <b>{!launchURLsInApp}</b>");
launchURLsInApp = !launchURLsInApp;
// Call setLaunchURLsInApp before the Initialize call
OneSignal.SetLaunchURLsInApp(launchURLsInApp);
}

public async void EnterLiveActivityAsync() {
_log($"Entering Live Activity with id: <b>{liveActivityId}</b> and token: <b>{liveActivityToken}</b> and awaiting result...");

Expand Down
Loading
Loading