com.onesignal.unity.ios 3.0.9 → 5.0.0-beta.2

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.
Files changed (55) hide show
  1. package/Editor/BuildPostProcessor.cs +4 -2
  2. package/Editor/OneSignaliOSDependencies.xml +5 -0
  3. package/Editor/OneSignaliOSDependencies.xml.meta +7 -0
  4. package/Editor/PBXProjectExtensions.cs +1 -1
  5. package/Runtime/OneSignaliOS.cs +178 -0
  6. package/Runtime/OneSignaliOS.cs.meta +11 -0
  7. package/Runtime/{OneSignalIOSInit.cs → OneSignaliOSInit.cs} +3 -3
  8. package/Runtime/OneSignaliOSInit.cs.meta +11 -0
  9. package/Runtime/Plugins/iOS/NotificationService.swift +1 -1
  10. package/Runtime/Plugins/iOS/OneSignalBridgeUtil.h +35 -0
  11. package/Runtime/Plugins/iOS/OneSignalBridgeUtil.h.meta +27 -0
  12. package/Runtime/Plugins/iOS/OneSignalBridgeUtil.mm +49 -0
  13. package/Runtime/Plugins/iOS/OneSignalBridgeUtil.mm.meta +37 -0
  14. package/Runtime/Plugins/iOS/OneSignalUnityBridge.mm +36 -383
  15. package/Runtime/Plugins/iOS/OneSignalUnityBridgeDebug.mm +40 -0
  16. package/Runtime/Plugins/iOS/OneSignalUnityBridgeDebug.mm.meta +37 -0
  17. package/Runtime/Plugins/iOS/OneSignalUnityBridgeInAppMessages.mm +167 -0
  18. package/Runtime/Plugins/iOS/OneSignalUnityBridgeInAppMessages.mm.meta +37 -0
  19. package/Runtime/Plugins/iOS/OneSignalUnityBridgeLocation.mm +44 -0
  20. package/Runtime/Plugins/iOS/OneSignalUnityBridgeLocation.mm.meta +37 -0
  21. package/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm +124 -0
  22. package/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm.meta +37 -0
  23. package/Runtime/Plugins/iOS/OneSignalUnityBridgeSession.mm +55 -0
  24. package/Runtime/Plugins/iOS/OneSignalUnityBridgeSession.mm.meta +37 -0
  25. package/Runtime/Plugins/iOS/OneSignalUnityBridgeUser.mm +197 -0
  26. package/Runtime/Plugins/iOS/OneSignalUnityBridgeUser.mm.meta +37 -0
  27. package/Runtime/Plugins/iOS/UIApplication+OneSignalUnity.mm +6 -3
  28. package/Runtime/Utilities/WaitingProxy.cs +52 -0
  29. package/Runtime/Utilities/WaitingProxy.cs.meta +11 -0
  30. package/Runtime/iOSDebugManager.cs +57 -0
  31. package/Runtime/iOSDebugManager.cs.meta +11 -0
  32. package/Runtime/iOSInAppMessagesManager.cs +118 -0
  33. package/Runtime/iOSInAppMessagesManager.cs.meta +11 -0
  34. package/Runtime/iOSLocationManager.cs +48 -0
  35. package/Runtime/iOSLocationManager.cs.meta +11 -0
  36. package/Runtime/iOSNotificationsManager.cs +148 -0
  37. package/Runtime/iOSNotificationsManager.cs.meta +11 -0
  38. package/Runtime/iOSPushSubscription.cs +81 -0
  39. package/Runtime/iOSPushSubscription.cs.meta +11 -0
  40. package/Runtime/iOSSessionManager.cs +47 -0
  41. package/Runtime/iOSSessionManager.cs.meta +11 -0
  42. package/Runtime/iOSUserManager.cs +106 -0
  43. package/Runtime/iOSUserManager.cs.meta +11 -0
  44. package/package.json +2 -2
  45. package/Editor/OneSignalIOSDependencies.xml +0 -5
  46. package/Editor/OneSignalIOSDependencies.xml.meta +0 -3
  47. package/Runtime/OneSignalIOS.Callbacks.cs +0 -181
  48. package/Runtime/OneSignalIOS.Callbacks.cs.meta +0 -3
  49. package/Runtime/OneSignalIOS.Interface.cs +0 -102
  50. package/Runtime/OneSignalIOS.Interface.cs.meta +0 -3
  51. package/Runtime/OneSignalIOS.Mappings.cs +0 -96
  52. package/Runtime/OneSignalIOS.Mappings.cs.meta +0 -3
  53. package/Runtime/OneSignalIOS.cs +0 -257
  54. package/Runtime/OneSignalIOS.cs.meta +0 -3
  55. package/Runtime/OneSignalIOSInit.cs.meta +0 -3
@@ -62,7 +62,9 @@ using UnityEditor.Build.Reporting;
62
62
  using UnityEditor.iOS.Xcode.Extensions;
63
63
  using Debug = UnityEngine.Debug;
64
64
 
65
- namespace OneSignalSDK {
65
+ using UnityEditor.Callbacks;
66
+
67
+ namespace OneSignalSDK.iOS {
66
68
  /// <summary>
67
69
  /// Adds required frameworks to the iOS project, and adds the OneSignalNotificationServiceExtension. Also handles
68
70
  /// making sure both targets (app and extension service) have the correct dependencies
@@ -70,7 +72,7 @@ namespace OneSignalSDK {
70
72
  public class BuildPostProcessor : IPostprocessBuildWithReport {
71
73
  private const string ServiceExtensionTargetName = "OneSignalNotificationServiceExtension";
72
74
  private const string ServiceExtensionFilename = "NotificationService.swift";
73
- private const string DependenciesFilename = "OneSignalIOSDependencies.xml";
75
+ private const string DependenciesFilename = "OneSignaliOSDependencies.xml";
74
76
  private const string PackageName = "com.onesignal.unity.ios";
75
77
 
76
78
  private static readonly string EditorFilesPath = Path.Combine("Packages", PackageName, "Editor");
@@ -0,0 +1,5 @@
1
+ <dependencies>
2
+ <iosPods>
3
+ <iosPod name="OneSignalXCFramework" version="5.0.0-beta-02" addToAllTargets="true" />
4
+ </iosPods>
5
+ </dependencies>
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 033a0fbaaa064a48ad2e72d8e35d5f36
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -28,7 +28,7 @@
28
28
  #if UNITY_IOS
29
29
  using UnityEditor.iOS.Xcode;
30
30
 
31
- namespace OneSignalSDK {
31
+ namespace OneSignalSDK.iOS {
32
32
  public static class PBXProjectExtensions {
33
33
  #if UNITY_2019_3_OR_NEWER
34
34
  public static string GetMainTargetName(this PBXProject project)
@@ -0,0 +1,178 @@
1
+ /*
2
+ * Modified MIT License
3
+ *
4
+ * Copyright 2022 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 System.Linq;
30
+ using System.Threading.Tasks;
31
+ using UnityEngine;
32
+ using System.Runtime.InteropServices;
33
+ using OneSignalSDK.iOS.Notifications;
34
+ using OneSignalSDK.iOS.InAppMessages;
35
+ using OneSignalSDK.iOS.Debug;
36
+ using OneSignalSDK.iOS.Location;
37
+ using OneSignalSDK.iOS.Session;
38
+ using OneSignalSDK.iOS.User;
39
+ using OneSignalSDK.iOS.Utilities;
40
+ using OneSignalSDK.Notifications;
41
+ using OneSignalSDK.InAppMessages;
42
+ using OneSignalSDK.Debug;
43
+ using OneSignalSDK.Debug.Utilities;
44
+ using OneSignalSDK.Location;
45
+ using OneSignalSDK.Session;
46
+ using OneSignalSDK.User;
47
+
48
+ namespace OneSignalSDK.iOS {
49
+ public sealed partial class OneSignaliOS : OneSignal {
50
+ [DllImport("__Internal")] private static extern bool _getPrivacyConsent();
51
+ [DllImport("__Internal")] private static extern void _setPrivacyConsent(bool consent);
52
+ [DllImport("__Internal")] private static extern bool _getRequiresPrivacyConsent();
53
+ [DllImport("__Internal")] private static extern void _setRequiresPrivacyConsent(bool required);
54
+ [DllImport("__Internal")] private static extern void _setLaunchURLsInApp(bool launchInApp);
55
+ [DllImport("__Internal")] private static extern void _initialize(string appId);
56
+ [DllImport("__Internal")] private static extern void _login(string externalId);
57
+ [DllImport("__Internal")] private static extern void _loginWithJwtBearerToken(string externalId, string jwtBearerToken);
58
+ [DllImport("__Internal")] private static extern void _logout();
59
+ [DllImport("__Internal")] private static extern void _enterLiveActivity(string activityId, string token, int hashCode, BooleanResponseDelegate callback);
60
+ [DllImport("__Internal")] private static extern void _exitLiveActivity(string activityId, int hashCode, BooleanResponseDelegate callback);
61
+
62
+ private delegate void BooleanResponseDelegate(int hashCode, bool response);
63
+
64
+ private iOSUserManager _user;
65
+ private iOSSessionManager _session;
66
+ private iOSNotificationsManager _notifications;
67
+ private iOSLocationManager _location;
68
+ private iOSInAppMessagesManager _inAppMessages;
69
+ private iOSDebugManager _debug;
70
+
71
+ private static OneSignaliOS _instance;
72
+
73
+ /// <summary>
74
+ /// Used to provide a reference for and sets up the global callbacks
75
+ /// </summary>
76
+ public OneSignaliOS() {
77
+ if (_instance != null)
78
+ SDKDebug.Error("Additional instance of OneSignaliOS created.");
79
+
80
+ _instance = this;
81
+ _debug = new iOSDebugManager();
82
+ }
83
+
84
+ public override IUserManager User {
85
+ get => _user;
86
+ }
87
+
88
+ public override ISessionManager Session {
89
+ get => _session;
90
+ }
91
+
92
+ public override INotificationsManager Notifications {
93
+ get => _notifications;
94
+ }
95
+
96
+ public override ILocationManager Location {
97
+ get => _location;
98
+ }
99
+
100
+ public override IInAppMessagesManager InAppMessages {
101
+ get => _inAppMessages;
102
+ }
103
+
104
+ public override IDebugManager Debug {
105
+ get => _debug;
106
+ }
107
+
108
+ public override bool PrivacyConsent {
109
+ get => _getPrivacyConsent();
110
+ set => _setPrivacyConsent(value);
111
+ }
112
+
113
+ public override bool RequiresPrivacyConsent {
114
+ get => _getRequiresPrivacyConsent();
115
+ set => _setRequiresPrivacyConsent(value);
116
+ }
117
+
118
+ public override void SetLaunchURLsInApp(bool launchInApp)
119
+ => _setLaunchURLsInApp(launchInApp);
120
+
121
+ public override void Initialize(string appId) {
122
+ _initialize(appId);
123
+
124
+ if (_inAppMessages == null) {
125
+ _inAppMessages = new iOSInAppMessagesManager();
126
+ _inAppMessages.Initialize();
127
+ }
128
+
129
+ if (_notifications == null) {
130
+ _notifications = new iOSNotificationsManager();
131
+ _notifications.Initialize();
132
+ }
133
+
134
+ if (_user == null) {
135
+ _user = new iOSUserManager();
136
+ _user.Initialize();
137
+ }
138
+
139
+ if (_location == null) {
140
+ _location = new iOSLocationManager();
141
+ }
142
+
143
+ if (_session == null) {
144
+ _session = new iOSSessionManager();
145
+ }
146
+
147
+ _completedInit(appId);
148
+ }
149
+
150
+ public override void Login(string externalId, string jwtBearerToken = null) {
151
+ if (jwtBearerToken == null) {
152
+ _login(externalId);
153
+ } else {
154
+ _loginWithJwtBearerToken(externalId, jwtBearerToken);
155
+ }
156
+ }
157
+
158
+ public override void Logout() {
159
+ _logout();
160
+ }
161
+
162
+ public override async Task<bool> EnterLiveActivity(string activityId, string token) {
163
+ var (proxy, hashCode) = WaitingProxy._setupProxy<bool>();
164
+ _enterLiveActivity(activityId, token, hashCode, BooleanCallbackProxy);
165
+ return await proxy;
166
+ }
167
+
168
+ public override async Task<bool> ExitLiveActivity(string activityId) {
169
+ var (proxy, hashCode) = WaitingProxy._setupProxy<bool>();
170
+ _exitLiveActivity(activityId, hashCode, BooleanCallbackProxy);
171
+ return await proxy;
172
+ }
173
+
174
+ [AOT.MonoPInvokeCallback(typeof(BooleanResponseDelegate))]
175
+ private static void BooleanCallbackProxy(int hashCode, bool response)
176
+ => WaitingProxy.ResolveCallbackProxy(hashCode, response);
177
+ }
178
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 2af5d93546b14794833229faccc49504
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -28,14 +28,14 @@
28
28
  #if UNITY_IOS && !UNITY_EDITOR
29
29
  using UnityEngine;
30
30
 
31
- namespace OneSignalSDK {
31
+ namespace OneSignalSDK.iOS {
32
32
  /// <summary>
33
33
  ///
34
34
  /// </summary>
35
- internal static class OneSignalIOSInit {
35
+ internal static class OneSignaliOSInit {
36
36
  [RuntimeInitializeOnLoadMethod] public static void Init() {
37
37
  if (!OneSignal.DidInitialize)
38
- OneSignal.Default = new OneSignalIOS();
38
+ OneSignal.Default = new OneSignaliOS();
39
39
  }
40
40
  }
41
41
  }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 2275cf034d2448b2953ee0863a6e7548
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,5 +1,5 @@
1
1
  import UserNotifications
2
- import OneSignal
2
+ import OneSignalFramework
3
3
 
4
4
  class NotificationService: UNNotificationServiceExtension {
5
5
  var contentHandler: ((UNNotificationContent) -> Void)?
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Modified MIT License
3
+ *
4
+ * Copyright 2022 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
+ #import <UIKit/UIKit.h>
29
+
30
+ @interface OneSignalBridgeUtil
31
+
32
+ const char* jsonStringFromDictionary(NSDictionary *dictionary);
33
+ // TObj objFromJsonString(const char* jsonString);
34
+
35
+ @end
@@ -0,0 +1,27 @@
1
+ fileFormatVersion: 2
2
+ guid: 34be6e6ca1e964b26a73be5e345bd15d
3
+ PluginImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ iconMap: {}
7
+ executionOrder: {}
8
+ defineConstraints: []
9
+ isPreloaded: 0
10
+ isOverridable: 1
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 1
13
+ platformData:
14
+ - first:
15
+ Any:
16
+ second:
17
+ enabled: 1
18
+ settings: {}
19
+ - first:
20
+ Editor: Editor
21
+ second:
22
+ enabled: 0
23
+ settings:
24
+ DefaultValueInitialized: true
25
+ userData:
26
+ assetBundleName:
27
+ assetBundleVariant:
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Modified MIT License
3
+ *
4
+ * Copyright 2022 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
+ #import "OneSignalBridgeUtil.h"
29
+
30
+ @implementation OneSignalBridgeUtil
31
+ const char* jsonStringFromDictionary(NSDictionary *dictionary) {
32
+ NSError *error;
33
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:&error];
34
+ NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
35
+ return [jsonString UTF8String];
36
+ }
37
+
38
+ // template <typename TObj>
39
+ // TObj objFromJsonString(const char* jsonString) {
40
+ // NSData* jsonData = [[NSString stringWithUTF8String:jsonString] dataUsingEncoding:NSUTF8StringEncoding];
41
+ // NSError* error = nil;
42
+ // TObj arr = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
43
+
44
+ // if (error != nil)
45
+ // return nil;
46
+
47
+ // return arr;
48
+ // }
49
+ @end
@@ -0,0 +1,37 @@
1
+ fileFormatVersion: 2
2
+ guid: a151050de45614602a5a8083463e1a4e
3
+ PluginImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ iconMap: {}
7
+ executionOrder: {}
8
+ defineConstraints: []
9
+ isPreloaded: 0
10
+ isOverridable: 1
11
+ isExplicitlyReferenced: 0
12
+ validateReferences: 1
13
+ platformData:
14
+ - first:
15
+ Any:
16
+ second:
17
+ enabled: 0
18
+ settings: {}
19
+ - first:
20
+ Editor: Editor
21
+ second:
22
+ enabled: 0
23
+ settings:
24
+ DefaultValueInitialized: true
25
+ - first:
26
+ iPhone: iOS
27
+ second:
28
+ enabled: 1
29
+ settings: {}
30
+ - first:
31
+ tvOS: tvOS
32
+ second:
33
+ enabled: 1
34
+ settings: {}
35
+ userData:
36
+ assetBundleName:
37
+ assetBundleVariant: