com.onesignal.unity.ios 5.1.15 → 5.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/BuildPostProcessor.cs +129 -57
- package/Editor/OneSignaliOSDependencies.xml +4 -4
- package/Editor/PBXProjectExtensions.cs +16 -15
- package/Runtime/AssemblyInfo.cs +1 -1
- package/Runtime/OneSignaliOS.cs +82 -43
- package/Runtime/Plugins/iOS/UIApplication+OneSignalUnity.mm +1 -1
- package/Runtime/Utilities/Later.cs +19 -11
- package/Runtime/Utilities/WaitingProxy.cs +15 -10
- package/Runtime/iOSDebugManager.cs +21 -12
- package/Runtime/iOSDisplayableNotification.cs +9 -7
- package/Runtime/iOSInAppMessagesManager.cs +84 -39
- package/Runtime/iOSLiveActivitiesManager.cs +60 -23
- package/Runtime/iOSLocationManager.cs +19 -10
- package/Runtime/iOSNotificationsManager.cs +111 -46
- package/Runtime/iOSPushSubscription.cs +40 -22
- package/Runtime/iOSSessionManager.cs +19 -14
- package/Runtime/iOSUserManager.cs +96 -58
- package/package.json +2 -2
|
@@ -61,23 +61,36 @@ using UnityEditor.Build;
|
|
|
61
61
|
using UnityEditor.Build.Reporting;
|
|
62
62
|
using UnityEditor.iOS.Xcode.Extensions;
|
|
63
63
|
using Debug = UnityEngine.Debug;
|
|
64
|
-
|
|
65
64
|
using UnityEditor.Callbacks;
|
|
66
65
|
|
|
67
|
-
namespace OneSignalSDK.iOS
|
|
66
|
+
namespace OneSignalSDK.iOS
|
|
67
|
+
{
|
|
68
68
|
/// <summary>
|
|
69
69
|
/// Adds required frameworks to the iOS project, and adds the OneSignalNotificationServiceExtension. Also handles
|
|
70
70
|
/// making sure both targets (app and extension service) have the correct dependencies
|
|
71
71
|
/// </summary>
|
|
72
|
-
public class BuildPostProcessor : IPostprocessBuildWithReport
|
|
72
|
+
public class BuildPostProcessor : IPostprocessBuildWithReport
|
|
73
|
+
{
|
|
73
74
|
private const string ServiceExtensionTargetName = "OneSignalNotificationServiceExtension";
|
|
74
75
|
private const string ServiceExtensionFilename = "NotificationService.swift";
|
|
75
76
|
private const string DependenciesFilename = "OneSignaliOSDependencies.xml";
|
|
76
77
|
private const string PackageName = "com.onesignal.unity.ios";
|
|
77
78
|
|
|
78
|
-
private static readonly string EditorFilesPath = Path.Combine(
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
private static readonly string EditorFilesPath = Path.Combine(
|
|
80
|
+
"Packages",
|
|
81
|
+
PackageName,
|
|
82
|
+
"Editor"
|
|
83
|
+
);
|
|
84
|
+
private static readonly string PluginLibrariesPath = Path.Combine(
|
|
85
|
+
PackageName,
|
|
86
|
+
"Runtime",
|
|
87
|
+
"Plugins",
|
|
88
|
+
"iOS"
|
|
89
|
+
);
|
|
90
|
+
private static readonly string PluginFilesPath = Path.Combine(
|
|
91
|
+
"Packages",
|
|
92
|
+
PluginLibrariesPath
|
|
93
|
+
);
|
|
81
94
|
|
|
82
95
|
private string _outputPath;
|
|
83
96
|
private string _projectPath;
|
|
@@ -96,18 +109,19 @@ namespace OneSignalSDK.iOS {
|
|
|
96
109
|
/// <summary>
|
|
97
110
|
/// Entry for the build post processing necessary to get the OneSignal SDK iOS up and running
|
|
98
111
|
/// </summary>
|
|
99
|
-
public void OnPostprocessBuild(BuildReport report)
|
|
112
|
+
public void OnPostprocessBuild(BuildReport report)
|
|
113
|
+
{
|
|
100
114
|
if (report.summary.platform != BuildTarget.iOS)
|
|
101
115
|
return;
|
|
102
116
|
|
|
103
117
|
// Load the project
|
|
104
|
-
_outputPath
|
|
118
|
+
_outputPath = report.summary.outputPath;
|
|
105
119
|
_projectPath = PBXProject.GetPBXProjectPath(_outputPath);
|
|
106
120
|
_project.ReadFromString(File.ReadAllText(_projectPath));
|
|
107
|
-
|
|
121
|
+
|
|
108
122
|
// Turn on capabilities required by OneSignal
|
|
109
123
|
AddProjectCapabilities();
|
|
110
|
-
|
|
124
|
+
|
|
111
125
|
// Add the service extension
|
|
112
126
|
AddNotificationServiceExtension();
|
|
113
127
|
|
|
@@ -120,22 +134,31 @@ namespace OneSignalSDK.iOS {
|
|
|
120
134
|
/// <summary>
|
|
121
135
|
/// Get existing entitlements file if exists or creates a new file, adds it to the project, and returns the path
|
|
122
136
|
/// </summary>
|
|
123
|
-
private string GetEntitlementsPath(string targetGuid, string targetName)
|
|
124
|
-
|
|
137
|
+
private string GetEntitlementsPath(string targetGuid, string targetName)
|
|
138
|
+
{
|
|
139
|
+
var relativePath = _project.GetBuildPropertyForAnyConfig(
|
|
140
|
+
targetGuid,
|
|
141
|
+
"CODE_SIGN_ENTITLEMENTS"
|
|
142
|
+
);
|
|
125
143
|
|
|
126
|
-
if (relativePath != null)
|
|
144
|
+
if (relativePath != null)
|
|
145
|
+
{
|
|
127
146
|
var fullPath = Path.Combine(_outputPath, relativePath);
|
|
128
147
|
|
|
129
148
|
if (File.Exists(fullPath))
|
|
130
149
|
return fullPath;
|
|
131
150
|
}
|
|
132
|
-
|
|
133
|
-
var entitlementsPath = Path.Combine(
|
|
134
|
-
|
|
151
|
+
|
|
152
|
+
var entitlementsPath = Path.Combine(
|
|
153
|
+
_outputPath,
|
|
154
|
+
targetName,
|
|
155
|
+
$"{targetName}.entitlements"
|
|
156
|
+
);
|
|
157
|
+
|
|
135
158
|
// make new file
|
|
136
159
|
var entitlementsPlist = new PlistDocument();
|
|
137
160
|
entitlementsPlist.WriteToFile(entitlementsPath);
|
|
138
|
-
|
|
161
|
+
|
|
139
162
|
// Copy the entitlement file to the xcode project
|
|
140
163
|
var entitlementFileName = Path.GetFileName(entitlementsPath);
|
|
141
164
|
var relativeDestination = targetName + "/" + entitlementFileName;
|
|
@@ -146,28 +169,34 @@ namespace OneSignalSDK.iOS {
|
|
|
146
169
|
|
|
147
170
|
return relativeDestination;
|
|
148
171
|
}
|
|
149
|
-
|
|
172
|
+
|
|
150
173
|
/// <summary>
|
|
151
174
|
/// Add the required capabilities and entitlements for OneSignal
|
|
152
175
|
/// </summary>
|
|
153
|
-
private void AddProjectCapabilities()
|
|
176
|
+
private void AddProjectCapabilities()
|
|
177
|
+
{
|
|
154
178
|
var targetGuid = _project.GetMainTargetGuid();
|
|
155
179
|
var targetName = _project.GetMainTargetName();
|
|
156
180
|
|
|
157
181
|
var entitlementsPath = GetEntitlementsPath(targetGuid, targetName);
|
|
158
|
-
var projCapability = new ProjectCapabilityManager(
|
|
182
|
+
var projCapability = new ProjectCapabilityManager(
|
|
183
|
+
_projectPath,
|
|
184
|
+
entitlementsPath,
|
|
185
|
+
targetName
|
|
186
|
+
);
|
|
159
187
|
|
|
160
188
|
projCapability.AddBackgroundModes(BackgroundModesOptions.RemoteNotifications);
|
|
161
189
|
projCapability.AddPushNotifications(false);
|
|
162
190
|
projCapability.AddAppGroups(new[] { _appGroupName });
|
|
163
|
-
|
|
191
|
+
|
|
164
192
|
projCapability.WriteToFile();
|
|
165
193
|
}
|
|
166
|
-
|
|
194
|
+
|
|
167
195
|
/// <summary>
|
|
168
196
|
/// Create and add the notification extension to the project
|
|
169
197
|
/// </summary>
|
|
170
|
-
private void AddNotificationServiceExtension()
|
|
198
|
+
private void AddNotificationServiceExtension()
|
|
199
|
+
{
|
|
171
200
|
#if !UNITY_CLOUD_BUILD
|
|
172
201
|
// refresh plist and podfile on appends
|
|
173
202
|
ExtensionCreatePlist(_outputPath);
|
|
@@ -179,9 +208,12 @@ namespace OneSignalSDK.iOS {
|
|
|
179
208
|
if (!string.IsNullOrEmpty(extensionGuid))
|
|
180
209
|
return;
|
|
181
210
|
|
|
182
|
-
extensionGuid = _project.AddAppExtension(
|
|
211
|
+
extensionGuid = _project.AddAppExtension(
|
|
212
|
+
_project.GetMainTargetGuid(),
|
|
183
213
|
ServiceExtensionTargetName,
|
|
184
|
-
PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS)
|
|
214
|
+
PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS)
|
|
215
|
+
+ "."
|
|
216
|
+
+ ServiceExtensionTargetName,
|
|
185
217
|
ServiceExtensionTargetName + "/" + "Info.plist" // Unix path as it's used by Xcode
|
|
186
218
|
);
|
|
187
219
|
|
|
@@ -192,20 +224,31 @@ namespace OneSignalSDK.iOS {
|
|
|
192
224
|
_project.SetBuildProperty(extensionGuid, "IPHONEOS_DEPLOYMENT_TARGET", "10.0");
|
|
193
225
|
_project.SetBuildProperty(extensionGuid, "SWIFT_VERSION", "5.0");
|
|
194
226
|
_project.SetBuildProperty(extensionGuid, "ARCHS", "arm64");
|
|
195
|
-
_project.SetBuildProperty(
|
|
227
|
+
_project.SetBuildProperty(
|
|
228
|
+
extensionGuid,
|
|
229
|
+
"DEVELOPMENT_TEAM",
|
|
230
|
+
PlayerSettings.iOS.appleDeveloperTeamID
|
|
231
|
+
);
|
|
196
232
|
_project.SetBuildProperty(extensionGuid, "ENABLE_BITCODE", "NO");
|
|
197
233
|
|
|
198
|
-
_project.AddBuildProperty(
|
|
199
|
-
|
|
234
|
+
_project.AddBuildProperty(
|
|
235
|
+
extensionGuid,
|
|
236
|
+
"LIBRARY_SEARCH_PATHS",
|
|
237
|
+
$"$(PROJECT_DIR)/Libraries/{PluginLibrariesPath.Replace("\\", "/")}"
|
|
238
|
+
);
|
|
200
239
|
|
|
201
240
|
_project.WriteToFile(_projectPath);
|
|
202
241
|
|
|
203
242
|
// add capabilities + entitlements
|
|
204
243
|
var entitlementsPath = GetEntitlementsPath(extensionGuid, ServiceExtensionTargetName);
|
|
205
|
-
var projCapability = new ProjectCapabilityManager(
|
|
206
|
-
|
|
244
|
+
var projCapability = new ProjectCapabilityManager(
|
|
245
|
+
_projectPath,
|
|
246
|
+
entitlementsPath,
|
|
247
|
+
ServiceExtensionTargetName
|
|
248
|
+
);
|
|
249
|
+
|
|
207
250
|
projCapability.AddAppGroups(new[] { _appGroupName });
|
|
208
|
-
|
|
251
|
+
|
|
209
252
|
projCapability.WriteToFile();
|
|
210
253
|
#endif
|
|
211
254
|
}
|
|
@@ -213,80 +256,109 @@ namespace OneSignalSDK.iOS {
|
|
|
213
256
|
/// <summary>
|
|
214
257
|
/// Add the swift source file required by the notification extension
|
|
215
258
|
/// </summary>
|
|
216
|
-
private void ExtensionAddSourceFiles(string extensionGuid)
|
|
217
|
-
|
|
218
|
-
var
|
|
219
|
-
var
|
|
259
|
+
private void ExtensionAddSourceFiles(string extensionGuid)
|
|
260
|
+
{
|
|
261
|
+
var buildPhaseID = _project.AddSourcesBuildPhase(extensionGuid);
|
|
262
|
+
var sourcePath = Path.Combine(PluginFilesPath, ServiceExtensionFilename);
|
|
263
|
+
var destPathRelative = Path.Combine(
|
|
264
|
+
ServiceExtensionTargetName,
|
|
265
|
+
ServiceExtensionFilename
|
|
266
|
+
);
|
|
220
267
|
|
|
221
268
|
var destPath = Path.Combine(_outputPath, destPathRelative);
|
|
222
269
|
if (!File.Exists(destPath))
|
|
223
|
-
FileUtil.CopyFileOrDirectory(
|
|
270
|
+
FileUtil.CopyFileOrDirectory(
|
|
271
|
+
sourcePath.Replace("\\", "/"),
|
|
272
|
+
destPath.Replace("\\", "/")
|
|
273
|
+
);
|
|
224
274
|
|
|
225
275
|
var sourceFileGuid = _project.AddFile(destPathRelative, destPathRelative);
|
|
226
276
|
_project.AddFileToBuildSection(extensionGuid, buildPhaseID, sourceFileGuid);
|
|
227
277
|
}
|
|
228
|
-
|
|
278
|
+
|
|
229
279
|
/// <summary>
|
|
230
280
|
/// Create a .plist file for the extension
|
|
231
281
|
/// </summary>
|
|
232
282
|
/// <remarks>NOTE: File in Xcode project is replaced everytime, never appends</remarks>
|
|
233
|
-
private bool ExtensionCreatePlist(string path)
|
|
283
|
+
private bool ExtensionCreatePlist(string path)
|
|
284
|
+
{
|
|
234
285
|
var extensionPath = Path.Combine(path, ServiceExtensionTargetName);
|
|
235
286
|
Directory.CreateDirectory(extensionPath);
|
|
236
287
|
|
|
237
|
-
var plistPath
|
|
288
|
+
var plistPath = Path.Combine(extensionPath, "Info.plist");
|
|
238
289
|
var alreadyExists = File.Exists(plistPath);
|
|
239
290
|
|
|
240
291
|
var notificationServicePlist = new PlistDocument();
|
|
241
292
|
notificationServicePlist.ReadFromFile(Path.Combine(PluginFilesPath, "Info.plist"));
|
|
242
|
-
notificationServicePlist.root.SetString(
|
|
243
|
-
|
|
293
|
+
notificationServicePlist.root.SetString(
|
|
294
|
+
"CFBundleShortVersionString",
|
|
295
|
+
PlayerSettings.bundleVersion
|
|
296
|
+
);
|
|
297
|
+
notificationServicePlist.root.SetString(
|
|
298
|
+
"CFBundleVersion",
|
|
299
|
+
PlayerSettings.iOS.buildNumber
|
|
300
|
+
);
|
|
244
301
|
|
|
245
302
|
notificationServicePlist.WriteToFile(plistPath);
|
|
246
|
-
|
|
303
|
+
|
|
247
304
|
return alreadyExists;
|
|
248
305
|
}
|
|
249
306
|
|
|
250
|
-
private void ExtensionAddPodsToTarget()
|
|
307
|
+
private void ExtensionAddPodsToTarget()
|
|
308
|
+
{
|
|
251
309
|
var podfilePath = Path.Combine(_outputPath, "Podfile");
|
|
252
310
|
|
|
253
|
-
if (!File.Exists(podfilePath))
|
|
254
|
-
|
|
311
|
+
if (!File.Exists(podfilePath))
|
|
312
|
+
{
|
|
313
|
+
Debug.LogError(
|
|
314
|
+
$"Could not find Podfile. {ServiceExtensionFilename} will have errors."
|
|
315
|
+
);
|
|
255
316
|
return;
|
|
256
317
|
}
|
|
257
318
|
|
|
258
319
|
var dependenciesFilePath = Path.Combine(EditorFilesPath, DependenciesFilename);
|
|
259
320
|
|
|
260
|
-
if (!File.Exists(dependenciesFilePath))
|
|
321
|
+
if (!File.Exists(dependenciesFilePath))
|
|
322
|
+
{
|
|
261
323
|
Debug.LogError($"Could not find {DependenciesFilename}");
|
|
262
324
|
return;
|
|
263
325
|
}
|
|
264
|
-
|
|
326
|
+
|
|
265
327
|
var dependenciesFile = File.ReadAllText(dependenciesFilePath);
|
|
266
|
-
var dependenciesRegex = new Regex(
|
|
328
|
+
var dependenciesRegex = new Regex(
|
|
329
|
+
"(?<=<iosPod name=\"OneSignalXCFramework\" version=\").+(?=\" addToAllTargets=\"true\" />)"
|
|
330
|
+
);
|
|
267
331
|
|
|
268
|
-
if (!dependenciesRegex.IsMatch(dependenciesFile))
|
|
269
|
-
|
|
332
|
+
if (!dependenciesRegex.IsMatch(dependenciesFile))
|
|
333
|
+
{
|
|
334
|
+
Debug.LogError(
|
|
335
|
+
$"Could not read current iOS framework dependency version from {DependenciesFilename}"
|
|
336
|
+
);
|
|
270
337
|
return;
|
|
271
338
|
}
|
|
272
339
|
|
|
273
340
|
var podfile = File.ReadAllText(podfilePath);
|
|
274
|
-
var podfileRegex = new Regex(
|
|
275
|
-
|
|
341
|
+
var podfileRegex = new Regex(
|
|
342
|
+
$@"target '{ServiceExtensionTargetName}' do\n pod 'OneSignalXCFramework', '(.+)'\nend\n"
|
|
343
|
+
);
|
|
344
|
+
|
|
276
345
|
var requiredVersion = dependenciesRegex.Match(dependenciesFile).ToString();
|
|
277
|
-
var requiredTarget =
|
|
346
|
+
var requiredTarget =
|
|
347
|
+
$"target '{ServiceExtensionTargetName}' do\n pod 'OneSignalXCFramework', '{requiredVersion}'\nend\n";
|
|
278
348
|
|
|
279
349
|
if (!podfileRegex.IsMatch(podfile))
|
|
280
350
|
podfile += requiredTarget;
|
|
281
|
-
else
|
|
351
|
+
else
|
|
352
|
+
{
|
|
282
353
|
var podfileTarget = podfileRegex.Match(podfile).ToString();
|
|
283
354
|
podfile = podfile.Replace(podfileTarget, requiredTarget);
|
|
284
355
|
}
|
|
285
|
-
|
|
356
|
+
|
|
286
357
|
File.WriteAllText(podfilePath, podfile);
|
|
287
358
|
}
|
|
288
359
|
|
|
289
|
-
private void DisableBitcode()
|
|
360
|
+
private void DisableBitcode()
|
|
361
|
+
{
|
|
290
362
|
// Main
|
|
291
363
|
var targetGuid = _project.GetMainTargetGuid();
|
|
292
364
|
_project.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");
|
|
@@ -301,4 +373,4 @@ namespace OneSignalSDK.iOS {
|
|
|
301
373
|
}
|
|
302
374
|
}
|
|
303
375
|
}
|
|
304
|
-
#endif
|
|
376
|
+
#endif
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<dependencies>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
</dependencies>
|
|
2
|
+
<iosPods>
|
|
3
|
+
<iosPod name="OneSignalXCFramework" version="5.2.16" addToAllTargets="true" />
|
|
4
|
+
</iosPods>
|
|
5
|
+
</dependencies>
|
|
@@ -28,21 +28,22 @@
|
|
|
28
28
|
#if UNITY_IOS
|
|
29
29
|
using UnityEditor.iOS.Xcode;
|
|
30
30
|
|
|
31
|
-
namespace OneSignalSDK.iOS
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
namespace OneSignalSDK.iOS
|
|
32
|
+
{
|
|
33
|
+
public static class PBXProjectExtensions
|
|
34
|
+
{
|
|
35
|
+
#if UNITY_2019_3_OR_NEWER
|
|
36
|
+
public static string GetMainTargetName(this PBXProject project) => "Unity-iPhone";
|
|
36
37
|
|
|
37
|
-
public static string GetMainTargetGuid(this PBXProject project)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
public static string GetMainTargetName(this PBXProject project)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
public static string GetMainTargetGuid(this PBXProject project)
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
public static string GetMainTargetGuid(this PBXProject project) =>
|
|
39
|
+
project.GetUnityMainTargetGuid();
|
|
40
|
+
#else
|
|
41
|
+
public static string GetMainTargetName(this PBXProject project) =>
|
|
42
|
+
PBXProject.GetUnityTargetName();
|
|
43
|
+
|
|
44
|
+
public static string GetMainTargetGuid(this PBXProject project) =>
|
|
45
|
+
project.TargetGuidByName(PBXProject.GetUnityTargetName());
|
|
46
|
+
#endif
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
#endif
|
|
49
|
+
#endif
|
package/Runtime/AssemblyInfo.cs
CHANGED
package/Runtime/OneSignaliOS.cs
CHANGED
|
@@ -25,35 +25,51 @@
|
|
|
25
25
|
* THE SOFTWARE.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
using UnityEngine;
|
|
29
|
-
using System.Linq;
|
|
30
|
-
using System.Threading.Tasks;
|
|
31
28
|
using System.Collections.Generic;
|
|
29
|
+
using System.Linq;
|
|
32
30
|
using System.Runtime.InteropServices;
|
|
33
|
-
using
|
|
34
|
-
using OneSignalSDK.InAppMessages;
|
|
31
|
+
using System.Threading.Tasks;
|
|
35
32
|
using OneSignalSDK.Debug;
|
|
36
33
|
using OneSignalSDK.Debug.Utilities;
|
|
37
|
-
using OneSignalSDK.
|
|
38
|
-
using OneSignalSDK.Session;
|
|
39
|
-
using OneSignalSDK.User;
|
|
40
|
-
using OneSignalSDK.LiveActivities;
|
|
41
|
-
using OneSignalSDK.iOS.Notifications;
|
|
42
|
-
using OneSignalSDK.iOS.InAppMessages;
|
|
34
|
+
using OneSignalSDK.InAppMessages;
|
|
43
35
|
using OneSignalSDK.iOS.Debug;
|
|
36
|
+
using OneSignalSDK.iOS.InAppMessages;
|
|
37
|
+
using OneSignalSDK.iOS.LiveActivities;
|
|
44
38
|
using OneSignalSDK.iOS.Location;
|
|
39
|
+
using OneSignalSDK.iOS.Notifications;
|
|
45
40
|
using OneSignalSDK.iOS.Session;
|
|
46
41
|
using OneSignalSDK.iOS.User;
|
|
47
|
-
using OneSignalSDK.
|
|
42
|
+
using OneSignalSDK.LiveActivities;
|
|
43
|
+
using OneSignalSDK.Location;
|
|
44
|
+
using OneSignalSDK.Notifications;
|
|
45
|
+
using OneSignalSDK.Session;
|
|
46
|
+
using OneSignalSDK.User;
|
|
47
|
+
using UnityEngine;
|
|
48
|
+
|
|
49
|
+
namespace OneSignalSDK.iOS
|
|
50
|
+
{
|
|
51
|
+
public sealed partial class OneSignaliOS : OneSignalPlatform
|
|
52
|
+
{
|
|
53
|
+
[DllImport("__Internal")]
|
|
54
|
+
private static extern void _oneSignalSetConsentGiven(bool consent);
|
|
55
|
+
|
|
56
|
+
[DllImport("__Internal")]
|
|
57
|
+
private static extern void _oneSignalSetConsentRequired(bool required);
|
|
58
|
+
|
|
59
|
+
[DllImport("__Internal")]
|
|
60
|
+
private static extern void _oneSignalInitialize(string appId);
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
[DllImport("__Internal")]
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
[DllImport("__Internal")]
|
|
63
|
+
private static extern void _oneSignalLogin(string externalId);
|
|
64
|
+
|
|
65
|
+
[DllImport("__Internal")]
|
|
66
|
+
private static extern void _oneSignalLoginWithJwtBearerToken(
|
|
67
|
+
string externalId,
|
|
68
|
+
string jwtBearerToken
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
[DllImport("__Internal")]
|
|
72
|
+
private static extern void _oneSignalLogout();
|
|
57
73
|
|
|
58
74
|
private iOSUserManager _user;
|
|
59
75
|
private iOSSessionManager _session;
|
|
@@ -68,8 +84,10 @@ namespace OneSignalSDK.iOS {
|
|
|
68
84
|
/// <summary>
|
|
69
85
|
/// Used to provide a reference for and sets up the global callbacks
|
|
70
86
|
/// </summary>
|
|
71
|
-
public OneSignaliOS()
|
|
72
|
-
|
|
87
|
+
public OneSignaliOS()
|
|
88
|
+
{
|
|
89
|
+
if (_instance != null)
|
|
90
|
+
{
|
|
73
91
|
SDKDebug.Error("Additional instance of OneSignaliOS created.");
|
|
74
92
|
return;
|
|
75
93
|
}
|
|
@@ -78,85 +96,106 @@ namespace OneSignalSDK.iOS {
|
|
|
78
96
|
_debug = new iOSDebugManager();
|
|
79
97
|
}
|
|
80
98
|
|
|
81
|
-
public override IUserManager User
|
|
99
|
+
public override IUserManager User
|
|
100
|
+
{
|
|
82
101
|
get => _user;
|
|
83
102
|
}
|
|
84
103
|
|
|
85
|
-
public override ISessionManager Session
|
|
104
|
+
public override ISessionManager Session
|
|
105
|
+
{
|
|
86
106
|
get => _session;
|
|
87
107
|
}
|
|
88
108
|
|
|
89
|
-
public override INotificationsManager Notifications
|
|
109
|
+
public override INotificationsManager Notifications
|
|
110
|
+
{
|
|
90
111
|
get => _notifications;
|
|
91
112
|
}
|
|
92
113
|
|
|
93
|
-
public override ILocationManager Location
|
|
114
|
+
public override ILocationManager Location
|
|
115
|
+
{
|
|
94
116
|
get => _location;
|
|
95
117
|
}
|
|
96
118
|
|
|
97
|
-
public override IInAppMessagesManager InAppMessages
|
|
119
|
+
public override IInAppMessagesManager InAppMessages
|
|
120
|
+
{
|
|
98
121
|
get => _inAppMessages;
|
|
99
122
|
}
|
|
100
123
|
|
|
101
|
-
public override IDebugManager Debug
|
|
124
|
+
public override IDebugManager Debug
|
|
125
|
+
{
|
|
102
126
|
get => _debug;
|
|
103
127
|
}
|
|
104
128
|
|
|
105
|
-
public override ILiveActivitiesManager LiveActivities
|
|
129
|
+
public override ILiveActivitiesManager LiveActivities
|
|
130
|
+
{
|
|
106
131
|
get => _liveActivities;
|
|
107
132
|
}
|
|
108
133
|
|
|
109
|
-
public override bool ConsentGiven
|
|
134
|
+
public override bool ConsentGiven
|
|
135
|
+
{
|
|
110
136
|
set => _oneSignalSetConsentGiven(value);
|
|
111
137
|
}
|
|
112
138
|
|
|
113
|
-
public override bool ConsentRequired
|
|
139
|
+
public override bool ConsentRequired
|
|
140
|
+
{
|
|
114
141
|
set => _oneSignalSetConsentRequired(value);
|
|
115
142
|
}
|
|
116
143
|
|
|
117
|
-
public override void Initialize(string appId)
|
|
144
|
+
public override void Initialize(string appId)
|
|
145
|
+
{
|
|
118
146
|
_oneSignalInitialize(appId);
|
|
119
147
|
|
|
120
|
-
if (_inAppMessages == null)
|
|
148
|
+
if (_inAppMessages == null)
|
|
149
|
+
{
|
|
121
150
|
_inAppMessages = new iOSInAppMessagesManager();
|
|
122
151
|
_inAppMessages.Initialize();
|
|
123
152
|
}
|
|
124
153
|
|
|
125
|
-
if (_notifications == null)
|
|
154
|
+
if (_notifications == null)
|
|
155
|
+
{
|
|
126
156
|
_notifications = new iOSNotificationsManager();
|
|
127
157
|
_notifications.Initialize();
|
|
128
158
|
}
|
|
129
159
|
|
|
130
|
-
if (_user == null)
|
|
160
|
+
if (_user == null)
|
|
161
|
+
{
|
|
131
162
|
_user = new iOSUserManager();
|
|
132
163
|
_user.Initialize();
|
|
133
164
|
}
|
|
134
165
|
|
|
135
|
-
if (_location == null)
|
|
166
|
+
if (_location == null)
|
|
167
|
+
{
|
|
136
168
|
_location = new iOSLocationManager();
|
|
137
169
|
}
|
|
138
170
|
|
|
139
|
-
if (_session == null)
|
|
171
|
+
if (_session == null)
|
|
172
|
+
{
|
|
140
173
|
_session = new iOSSessionManager();
|
|
141
174
|
}
|
|
142
175
|
|
|
143
|
-
if (_liveActivities == null)
|
|
176
|
+
if (_liveActivities == null)
|
|
177
|
+
{
|
|
144
178
|
_liveActivities = new iOSLiveActivitiesManager();
|
|
145
179
|
}
|
|
146
180
|
|
|
147
181
|
_completedInit(appId);
|
|
148
182
|
}
|
|
149
183
|
|
|
150
|
-
public override void Login(string externalId, string jwtBearerToken = null)
|
|
151
|
-
|
|
184
|
+
public override void Login(string externalId, string jwtBearerToken = null)
|
|
185
|
+
{
|
|
186
|
+
if (jwtBearerToken == null)
|
|
187
|
+
{
|
|
152
188
|
_oneSignalLogin(externalId);
|
|
153
|
-
}
|
|
189
|
+
}
|
|
190
|
+
else
|
|
191
|
+
{
|
|
154
192
|
_oneSignalLoginWithJwtBearerToken(externalId, jwtBearerToken);
|
|
155
193
|
}
|
|
156
194
|
}
|
|
157
195
|
|
|
158
|
-
public override void Logout()
|
|
196
|
+
public override void Logout()
|
|
197
|
+
{
|
|
159
198
|
_oneSignalLogout();
|
|
160
199
|
}
|
|
161
200
|
}
|
|
162
|
-
}
|
|
201
|
+
}
|
|
@@ -97,7 +97,7 @@ static bool swizzled = false;
|
|
|
97
97
|
|
|
98
98
|
- (BOOL)oneSignalApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
99
99
|
[OneSignalWrapper setSdkType:@"unity"];
|
|
100
|
-
[OneSignalWrapper setSdkVersion:@"
|
|
100
|
+
[OneSignalWrapper setSdkVersion:@"005116"];
|
|
101
101
|
[OneSignal initialize:nil withLaunchOptions:launchOptions];
|
|
102
102
|
|
|
103
103
|
if ([self respondsToSelector:@selector(oneSignalApplication:didFinishLaunchingWithOptions:)])
|