|
1 | | -/* |
2 | | - * Modified MIT License |
3 | | - * |
4 | | - * Copyright 2023 OneSignal |
5 | | - * |
6 | | - * Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | | - * of this software and associated documentation files (the "Software"), to deal |
8 | | - * in the Software without restriction, including without limitation the rights |
9 | | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
10 | | - * copies of the Software, and to permit persons to whom the Software is |
11 | | - * furnished to do so, subject to the following conditions: |
12 | | - * |
13 | | - * 1. The above copyright notice and this permission notice shall be included in |
14 | | - * all copies or substantial portions of the Software. |
15 | | - * |
16 | | - * 2. All copies of substantial portions of the Software may only be used in connection |
17 | | - * with services provided by OneSignal. |
18 | | - * |
19 | | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | - * THE SOFTWARE. |
26 | | - */ |
27 | | - |
28 | | -using System.Collections.Generic; |
29 | | -using OneSignalSDK.Debug; |
30 | | -using OneSignalSDK.InAppMessages; |
31 | | -using OneSignalSDK.LiveActivities; |
32 | | -using OneSignalSDK.Location; |
33 | | -using OneSignalSDK.Notifications; |
34 | | -using OneSignalSDK.Session; |
35 | | -using OneSignalSDK.User; |
36 | | -using UnityEngine; |
37 | | - |
38 | | -namespace OneSignalSDK |
39 | | -{ |
40 | | - /// <summary> |
41 | | - /// OneSignal SDK for Unity |
42 | | - /// </summary> |
43 | | - public static partial class OneSignal |
44 | | - { |
45 | | - public const string Version = "6.0.0"; |
46 | | - |
47 | | - /// <summary> |
48 | | - /// The default static instance of the OneSignal Unity SDK |
49 | | - /// </summary> |
50 | | - public static OneSignalPlatform Default |
51 | | - { |
52 | | - get { return _getDefaultInstance(); } |
53 | | - } |
54 | | - |
55 | | - /// <summary> |
56 | | - /// The user manager for accessing user-scoped management. Initialized only after [initWithContext] |
57 | | - /// has been called, and initialized with a device-scoped user until (or if) [login] has been |
58 | | - /// called. |
59 | | - /// </summary> |
60 | | - public static IUserManager User |
61 | | - { |
62 | | - get { return OneSignal.Default.User; } |
63 | | - } |
64 | | - |
65 | | - /// <summary> |
66 | | - /// The session manager for accessing session-scoped management. Initialized only after [initWithContext] |
67 | | - /// has been called. |
68 | | - /// </summary> |
69 | | - public static ISessionManager Session |
70 | | - { |
71 | | - get { return OneSignal.Default.Session; } |
72 | | - } |
73 | | - |
74 | | - /// <summary> |
75 | | - /// The notification manager for accessing device-scoped notification management. Initialized |
76 | | - /// only after [initWithContext] has been called. |
77 | | - /// </summary> |
78 | | - public static INotificationsManager Notifications |
79 | | - { |
80 | | - get { return OneSignal.Default.Notifications; } |
81 | | - } |
82 | | - |
83 | | - /// <summary> |
84 | | - /// The notification manager for accessing device-scoped notification management. Initialized |
85 | | - /// only after [initWithContext] has been called. |
86 | | - /// </summary> |
87 | | - public static ILocationManager Location |
88 | | - { |
89 | | - get { return OneSignal.Default.Location; } |
90 | | - } |
91 | | - |
92 | | - /// <summary> |
93 | | - /// The In-App Messaging manager for accessing device-scoped IAP management. Initialized |
94 | | - /// only after [initWithContext] has been called. |
95 | | - /// </summary> |
96 | | - public static IInAppMessagesManager InAppMessages |
97 | | - { |
98 | | - get { return OneSignal.Default.InAppMessages; } |
99 | | - } |
100 | | - |
101 | | - /// <summary> |
102 | | - /// Access to debug the SDK in the additional information is required to diagnose any |
103 | | - /// SDK-related issues. Initialized immediately (can be used prior to [initWithContext]). |
104 | | - /// |
105 | | - /// WARNING: This should not be used in a production setting. |
106 | | - /// |
107 | | - /// </summary> |
108 | | - public static IDebugManager Debug |
109 | | - { |
110 | | - get { return OneSignal.Default.Debug; } |
111 | | - } |
112 | | - |
113 | | - /// <summary> |
114 | | - /// Access to debug the SDK in the additional information is required to diagnose any |
115 | | - /// SDK-related issues. Initialized immediately (can be used prior to [initWithContext]). |
116 | | - /// |
117 | | - /// WARNING: This should not be used in a production setting. |
118 | | - /// |
119 | | - /// </summary> |
120 | | - public static ILiveActivitiesManager LiveActivities |
121 | | - { |
122 | | - get { return OneSignal.Default.LiveActivities; } |
123 | | - } |
124 | | - |
125 | | - /// <summary> |
126 | | - /// Provides privacy consent. OneSignal Unity SDK will not initialize until this is true. |
127 | | - /// </summary> |
128 | | - public static bool ConsentGiven |
129 | | - { |
130 | | - set => OneSignal.Default.ConsentGiven = value; |
131 | | - } |
132 | | - |
133 | | - /// <summary> |
134 | | - /// Allows you to delay the initialization of the SDK until <see cref="ConsentGiven"/> is set to true. Must |
135 | | - /// be set before <see cref="Initialize"/> is called. |
136 | | - /// </summary> |
137 | | - public static bool ConsentRequired |
138 | | - { |
139 | | - set => OneSignal.Default.ConsentRequired = value; |
140 | | - } |
141 | | - |
142 | | - /// <summary> |
143 | | - /// Starts the OneSignal SDK |
144 | | - /// </summary> |
145 | | - /// <param name="appId">Your application id from the OneSignal dashboard</param> |
146 | | - public static void Initialize(string appId) |
147 | | - { |
148 | | - OneSignal.Default.Initialize(appId); |
149 | | - } |
150 | | - |
151 | | - /// <summary> |
152 | | - /// Login to OneSignal under the user identified by the [externalId] provided. The act of |
153 | | - /// logging a user into the OneSignal SDK will switch the [user] context to that specific user. |
154 | | - /// |
155 | | - /// * If the [externalId] exists the user will be retrieved and the context set from that |
156 | | - /// user information. If operations have already been performed under a guest user, they |
157 | | - /// *will not* be applied to the now logged in user (they will be lost). |
158 | | - /// * If the [externalId] does not exist the user will be created and the context set from |
159 | | - /// the current local state. If operations have already been performed under a guest user |
160 | | - /// those operations *will* be applied to the newly created user. |
161 | | - /// |
162 | | - /// *Push Notifications and In-App Messaging* |
163 | | - /// Logging in a new user will automatically transfer push notification and in-app messaging |
164 | | - /// subscriptions from the current user (if there is one) to the newly logged in user. This is |
165 | | - /// because both Push and IAM are owned by the device. |
166 | | - /// </summary> |
167 | | - /// <param name="externalId">The external ID of the user that is to be logged in.</param> |
168 | | - /// <param name="jwtBearerToken"> |
169 | | - /// The optional JWT bearer token generated by your backend to establish |
170 | | - /// trust for the login operation. Required when identity verification has been enabled. See |
171 | | - /// [Identity Verification | OneSignal](https://documentation.onesignal.com/docs/identity-verification) |
172 | | - /// </param> |
173 | | - public static void Login(string externalId, string jwtBearerToken = null) |
174 | | - { |
175 | | - OneSignal.Default.Login(externalId, jwtBearerToken); |
176 | | - } |
177 | | - |
178 | | - /// <summary> |
179 | | - /// Logout the user previously logged in via [login]. The [user] property now references |
180 | | - /// a new device-scoped user. A device-scoped user has no user identity that can later |
181 | | - /// be retrieved, except through this device as long as the app remains installed and the app |
182 | | - /// data is not cleared. |
183 | | - /// </summary> |
184 | | - public static void Logout() |
185 | | - { |
186 | | - OneSignal.Default.Logout(); |
187 | | - } |
188 | | - } |
189 | | -} |
| 1 | +/* |
| 2 | + * Modified MIT License |
| 3 | + * |
| 4 | + * Copyright 2023 OneSignal |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * 1. The above copyright notice and this permission notice shall be included in |
| 14 | + * all copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * 2. All copies of substantial portions of the Software may only be used in connection |
| 17 | + * with services provided by OneSignal. |
| 18 | + * |
| 19 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 22 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 24 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 25 | + * THE SOFTWARE. |
| 26 | + */ |
| 27 | + |
| 28 | +using System.Collections.Generic; |
| 29 | +using OneSignalSDK.Debug; |
| 30 | +using OneSignalSDK.InAppMessages; |
| 31 | +using OneSignalSDK.LiveActivities; |
| 32 | +using OneSignalSDK.Location; |
| 33 | +using OneSignalSDK.Notifications; |
| 34 | +using OneSignalSDK.Session; |
| 35 | +using OneSignalSDK.User; |
| 36 | +using UnityEngine; |
| 37 | + |
| 38 | +namespace OneSignalSDK |
| 39 | +{ |
| 40 | + /// <summary> |
| 41 | + /// OneSignal SDK for Unity |
| 42 | + /// </summary> |
| 43 | + public static partial class OneSignal |
| 44 | + { |
| 45 | + public const string Version = "6.0.0"; |
| 46 | + |
| 47 | + /// <summary> |
| 48 | + /// The default static instance of the OneSignal Unity SDK |
| 49 | + /// </summary> |
| 50 | + public static OneSignalPlatform Default |
| 51 | + { |
| 52 | + get { return _getDefaultInstance(); } |
| 53 | + } |
| 54 | + |
| 55 | + /// <summary> |
| 56 | + /// The user manager for accessing user-scoped management. Initialized only after [initWithContext] |
| 57 | + /// has been called, and initialized with a device-scoped user until (or if) [login] has been |
| 58 | + /// called. |
| 59 | + /// </summary> |
| 60 | + public static IUserManager User |
| 61 | + { |
| 62 | + get { return OneSignal.Default.User; } |
| 63 | + } |
| 64 | + |
| 65 | + /// <summary> |
| 66 | + /// The session manager for accessing session-scoped management. Initialized only after [initWithContext] |
| 67 | + /// has been called. |
| 68 | + /// </summary> |
| 69 | + public static ISessionManager Session |
| 70 | + { |
| 71 | + get { return OneSignal.Default.Session; } |
| 72 | + } |
| 73 | + |
| 74 | + /// <summary> |
| 75 | + /// The notification manager for accessing device-scoped notification management. Initialized |
| 76 | + /// only after [initWithContext] has been called. |
| 77 | + /// </summary> |
| 78 | + public static INotificationsManager Notifications |
| 79 | + { |
| 80 | + get { return OneSignal.Default.Notifications; } |
| 81 | + } |
| 82 | + |
| 83 | + /// <summary> |
| 84 | + /// The notification manager for accessing device-scoped notification management. Initialized |
| 85 | + /// only after [initWithContext] has been called. |
| 86 | + /// </summary> |
| 87 | + public static ILocationManager Location |
| 88 | + { |
| 89 | + get { return OneSignal.Default.Location; } |
| 90 | + } |
| 91 | + |
| 92 | + /// <summary> |
| 93 | + /// The In-App Messaging manager for accessing device-scoped IAP management. Initialized |
| 94 | + /// only after [initWithContext] has been called. |
| 95 | + /// </summary> |
| 96 | + public static IInAppMessagesManager InAppMessages |
| 97 | + { |
| 98 | + get { return OneSignal.Default.InAppMessages; } |
| 99 | + } |
| 100 | + |
| 101 | + /// <summary> |
| 102 | + /// Access to debug the SDK in the additional information is required to diagnose any |
| 103 | + /// SDK-related issues. Initialized immediately (can be used prior to [initWithContext]). |
| 104 | + /// |
| 105 | + /// WARNING: This should not be used in a production setting. |
| 106 | + /// |
| 107 | + /// </summary> |
| 108 | + public static IDebugManager Debug |
| 109 | + { |
| 110 | + get { return OneSignal.Default.Debug; } |
| 111 | + } |
| 112 | + |
| 113 | + /// <summary> |
| 114 | + /// Access to debug the SDK in the additional information is required to diagnose any |
| 115 | + /// SDK-related issues. Initialized immediately (can be used prior to [initWithContext]). |
| 116 | + /// |
| 117 | + /// WARNING: This should not be used in a production setting. |
| 118 | + /// |
| 119 | + /// </summary> |
| 120 | + public static ILiveActivitiesManager LiveActivities |
| 121 | + { |
| 122 | + get { return OneSignal.Default.LiveActivities; } |
| 123 | + } |
| 124 | + |
| 125 | + /// <summary> |
| 126 | + /// Provides privacy consent. OneSignal Unity SDK will not initialize until this is true. |
| 127 | + /// </summary> |
| 128 | + public static bool ConsentGiven |
| 129 | + { |
| 130 | + set => OneSignal.Default.ConsentGiven = value; |
| 131 | + } |
| 132 | + |
| 133 | + /// <summary> |
| 134 | + /// Allows you to delay the initialization of the SDK until <see cref="ConsentGiven"/> is set to true. Must |
| 135 | + /// be set before <see cref="Initialize"/> is called. |
| 136 | + /// </summary> |
| 137 | + public static bool ConsentRequired |
| 138 | + { |
| 139 | + set => OneSignal.Default.ConsentRequired = value; |
| 140 | + } |
| 141 | + |
| 142 | + /// <summary> |
| 143 | + /// Starts the OneSignal SDK |
| 144 | + /// </summary> |
| 145 | + /// <param name="appId">Your application id from the OneSignal dashboard</param> |
| 146 | + public static void Initialize(string appId) |
| 147 | + { |
| 148 | + OneSignal.Default.Initialize(appId); |
| 149 | + } |
| 150 | + |
| 151 | + /// <summary> |
| 152 | + /// Login to OneSignal under the user identified by the [externalId] provided. The act of |
| 153 | + /// logging a user into the OneSignal SDK will switch the [user] context to that specific user. |
| 154 | + /// |
| 155 | + /// * If the [externalId] exists the user will be retrieved and the context set from that |
| 156 | + /// user information. If operations have already been performed under a guest user, they |
| 157 | + /// *will not* be applied to the now logged in user (they will be lost). |
| 158 | + /// * If the [externalId] does not exist the user will be created and the context set from |
| 159 | + /// the current local state. If operations have already been performed under a guest user |
| 160 | + /// those operations *will* be applied to the newly created user. |
| 161 | + /// |
| 162 | + /// *Push Notifications and In-App Messaging* |
| 163 | + /// Logging in a new user will automatically transfer push notification and in-app messaging |
| 164 | + /// subscriptions from the current user (if there is one) to the newly logged in user. This is |
| 165 | + /// because both Push and IAM are owned by the device. |
| 166 | + /// </summary> |
| 167 | + /// <param name="externalId">The external ID of the user that is to be logged in.</param> |
| 168 | + /// <param name="jwtBearerToken"> |
| 169 | + /// The optional JWT bearer token generated by your backend to establish |
| 170 | + /// trust for the login operation. Required when identity verification has been enabled. See |
| 171 | + /// [Identity Verification | OneSignal](https://documentation.onesignal.com/docs/identity-verification) |
| 172 | + /// </param> |
| 173 | + public static void Login(string externalId, string jwtBearerToken = null) |
| 174 | + { |
| 175 | + OneSignal.Default.Login(externalId, jwtBearerToken); |
| 176 | + } |
| 177 | + |
| 178 | + /// <summary> |
| 179 | + /// Logout the user previously logged in via [login]. The [user] property now references |
| 180 | + /// a new device-scoped user. A device-scoped user has no user identity that can later |
| 181 | + /// be retrieved, except through this device as long as the app remains installed and the app |
| 182 | + /// data is not cleared. |
| 183 | + /// </summary> |
| 184 | + public static void Logout() |
| 185 | + { |
| 186 | + OneSignal.Default.Logout(); |
| 187 | + } |
| 188 | + } |
| 189 | +} |
0 commit comments