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.
- package/Editor/BuildPostProcessor.cs +4 -2
- package/Editor/OneSignaliOSDependencies.xml +5 -0
- package/Editor/OneSignaliOSDependencies.xml.meta +7 -0
- package/Editor/PBXProjectExtensions.cs +1 -1
- package/Runtime/OneSignaliOS.cs +178 -0
- package/Runtime/OneSignaliOS.cs.meta +11 -0
- package/Runtime/{OneSignalIOSInit.cs → OneSignaliOSInit.cs} +3 -3
- package/Runtime/OneSignaliOSInit.cs.meta +11 -0
- package/Runtime/Plugins/iOS/NotificationService.swift +1 -1
- package/Runtime/Plugins/iOS/OneSignalBridgeUtil.h +35 -0
- package/Runtime/Plugins/iOS/OneSignalBridgeUtil.h.meta +27 -0
- package/Runtime/Plugins/iOS/OneSignalBridgeUtil.mm +49 -0
- package/Runtime/Plugins/iOS/OneSignalBridgeUtil.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridge.mm +36 -383
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeDebug.mm +40 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeDebug.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeInAppMessages.mm +167 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeInAppMessages.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeLocation.mm +44 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeLocation.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm +124 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeNotifications.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeSession.mm +55 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeSession.mm.meta +37 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeUser.mm +197 -0
- package/Runtime/Plugins/iOS/OneSignalUnityBridgeUser.mm.meta +37 -0
- package/Runtime/Plugins/iOS/UIApplication+OneSignalUnity.mm +6 -3
- package/Runtime/Utilities/WaitingProxy.cs +52 -0
- package/Runtime/Utilities/WaitingProxy.cs.meta +11 -0
- package/Runtime/iOSDebugManager.cs +57 -0
- package/Runtime/iOSDebugManager.cs.meta +11 -0
- package/Runtime/iOSInAppMessagesManager.cs +118 -0
- package/Runtime/iOSInAppMessagesManager.cs.meta +11 -0
- package/Runtime/iOSLocationManager.cs +48 -0
- package/Runtime/iOSLocationManager.cs.meta +11 -0
- package/Runtime/iOSNotificationsManager.cs +148 -0
- package/Runtime/iOSNotificationsManager.cs.meta +11 -0
- package/Runtime/iOSPushSubscription.cs +81 -0
- package/Runtime/iOSPushSubscription.cs.meta +11 -0
- package/Runtime/iOSSessionManager.cs +47 -0
- package/Runtime/iOSSessionManager.cs.meta +11 -0
- package/Runtime/iOSUserManager.cs +106 -0
- package/Runtime/iOSUserManager.cs.meta +11 -0
- package/package.json +2 -2
- package/Editor/OneSignalIOSDependencies.xml +0 -5
- package/Editor/OneSignalIOSDependencies.xml.meta +0 -3
- package/Runtime/OneSignalIOS.Callbacks.cs +0 -181
- package/Runtime/OneSignalIOS.Callbacks.cs.meta +0 -3
- package/Runtime/OneSignalIOS.Interface.cs +0 -102
- package/Runtime/OneSignalIOS.Interface.cs.meta +0 -3
- package/Runtime/OneSignalIOS.Mappings.cs +0 -96
- package/Runtime/OneSignalIOS.Mappings.cs.meta +0 -3
- package/Runtime/OneSignalIOS.cs +0 -257
- package/Runtime/OneSignalIOS.cs.meta +0 -3
- package/Runtime/OneSignalIOSInit.cs.meta +0 -3
|
@@ -0,0 +1,106 @@
|
|
|
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
|
+
|
|
29
|
+
using UnityEngine;
|
|
30
|
+
using System.Collections.Generic;
|
|
31
|
+
using System.Runtime.InteropServices;
|
|
32
|
+
using OneSignalSDK.User;
|
|
33
|
+
using OneSignalSDK.User.Models;
|
|
34
|
+
using OneSignalSDK.iOS.User.Models;
|
|
35
|
+
|
|
36
|
+
namespace OneSignalSDK.iOS.User {
|
|
37
|
+
internal sealed class iOSUserManager : IUserManager {
|
|
38
|
+
[DllImport("__Internal")] private static extern void _userSetLanguage(string languageCode);
|
|
39
|
+
[DllImport("__Internal")] private static extern void _userAddAlias(string aliasLabel, string aliasId);
|
|
40
|
+
[DllImport("__Internal")] private static extern void _userAddAliases(string aliasesJson);
|
|
41
|
+
[DllImport("__Internal")] private static extern void _userRemoveAlias(string aliasLabel);
|
|
42
|
+
[DllImport("__Internal")] private static extern void _userRemoveAliases(string aliasesJson);
|
|
43
|
+
[DllImport("__Internal")] private static extern void _userAddEmail(string email);
|
|
44
|
+
[DllImport("__Internal")] private static extern void _userRemoveEmail(string email);
|
|
45
|
+
[DllImport("__Internal")] private static extern void _userAddSms(string smsNumber);
|
|
46
|
+
[DllImport("__Internal")] private static extern void _userRemoveSms(string smsNumber);
|
|
47
|
+
[DllImport("__Internal")] private static extern void _userAddTag(string key, string value);
|
|
48
|
+
[DllImport("__Internal")] private static extern void _userAddTags(string tagsJson);
|
|
49
|
+
[DllImport("__Internal")] private static extern void _userRemoveTag(string key);
|
|
50
|
+
[DllImport("__Internal")] private static extern void _userRemoveTags(string tagsJson);
|
|
51
|
+
|
|
52
|
+
private iOSPushSubscription _pushSubscription;
|
|
53
|
+
|
|
54
|
+
public iOSUserManager() {
|
|
55
|
+
_pushSubscription = new iOSPushSubscription();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public IPushSubscription PushSubscription {
|
|
59
|
+
get => _pushSubscription;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public string Language {
|
|
63
|
+
set => _userSetLanguage(value);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public void AddTag(string key, string value)
|
|
67
|
+
=>_userAddTag(key, value);
|
|
68
|
+
|
|
69
|
+
public void AddTags(Dictionary<string, string> tags)
|
|
70
|
+
=> _userAddTags(Json.Serialize(tags));
|
|
71
|
+
|
|
72
|
+
public void RemoveTag(string key)
|
|
73
|
+
=> _userRemoveTag(key);
|
|
74
|
+
|
|
75
|
+
public void RemoveTags(params string[] keys)
|
|
76
|
+
=> _userRemoveTags(Json.Serialize(keys));
|
|
77
|
+
|
|
78
|
+
public void AddAlias(string label, string id)
|
|
79
|
+
=> _userAddAlias(label, id);
|
|
80
|
+
|
|
81
|
+
public void AddAliases(Dictionary<string, string> aliases)
|
|
82
|
+
=> _userAddAliases(Json.Serialize(aliases));
|
|
83
|
+
|
|
84
|
+
public void RemoveAlias(string label)
|
|
85
|
+
=> _userRemoveAlias(label);
|
|
86
|
+
|
|
87
|
+
public void RemoveAliases(params string[] labels)
|
|
88
|
+
=> _userRemoveAliases(Json.Serialize(labels));
|
|
89
|
+
|
|
90
|
+
public void AddEmail(string email)
|
|
91
|
+
=> _userAddEmail(email);
|
|
92
|
+
|
|
93
|
+
public void RemoveEmail(string email)
|
|
94
|
+
=> _userRemoveEmail(email);
|
|
95
|
+
|
|
96
|
+
public void AddSms(string sms)
|
|
97
|
+
=> _userAddSms(sms);
|
|
98
|
+
|
|
99
|
+
public void RemoveSms(string sms)
|
|
100
|
+
=> _userRemoveSms(sms);
|
|
101
|
+
|
|
102
|
+
public void Initialize() {
|
|
103
|
+
_pushSubscription.Initialize();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.onesignal.unity.ios",
|
|
3
3
|
"displayName": "OneSignal Unity SDK - iOS",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-beta.2",
|
|
5
5
|
"unity": "2018.4",
|
|
6
6
|
"description": "OneSignal is the market leader in customer engagement, powering mobile push, web push, email, and in-app messages.",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"com.onesignal.unity.core": "
|
|
8
|
+
"com.onesignal.unity.core": "5.0.0-beta.2"
|
|
9
9
|
},
|
|
10
10
|
"keywords": [
|
|
11
11
|
"push-notifications",
|
|
@@ -1,181 +0,0 @@
|
|
|
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 Laters;
|
|
30
|
-
using UnityEngine;
|
|
31
|
-
|
|
32
|
-
namespace OneSignalSDK {
|
|
33
|
-
public sealed partial class OneSignalIOS : OneSignal {
|
|
34
|
-
private delegate void BooleanResponseDelegate(int hashCode, bool response);
|
|
35
|
-
private delegate void StringResponseDelegate(int hashCode, string response);
|
|
36
|
-
|
|
37
|
-
private delegate void BooleanListenerDelegate(bool response);
|
|
38
|
-
private delegate void StringListenerDelegate(string response);
|
|
39
|
-
private delegate void StateListenerDelegate(string current, string previous);
|
|
40
|
-
|
|
41
|
-
private delegate bool NotificationWillShowInForegroundDelegate(string notification);
|
|
42
|
-
|
|
43
|
-
private static readonly Dictionary<int, ILater> WaitingProxies = new Dictionary<int, ILater>();
|
|
44
|
-
|
|
45
|
-
private static (Later<TResult> proxy, int hashCode) _setupProxy<TResult>() {
|
|
46
|
-
var proxy = new Later<TResult>();
|
|
47
|
-
var hashCode = proxy.GetHashCode();
|
|
48
|
-
WaitingProxies[hashCode] = proxy;
|
|
49
|
-
return (proxy, hashCode);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private static void ResolveCallbackProxy<TResponse>(int hashCode, TResponse response) {
|
|
53
|
-
if (!WaitingProxies.ContainsKey(hashCode))
|
|
54
|
-
return;
|
|
55
|
-
|
|
56
|
-
if (WaitingProxies[hashCode] is Later<TResponse> later)
|
|
57
|
-
later.Complete(response);
|
|
58
|
-
|
|
59
|
-
WaitingProxies.Remove(hashCode);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
[AOT.MonoPInvokeCallback(typeof(BooleanResponseDelegate))]
|
|
63
|
-
private static void BooleanCallbackProxy(int hashCode, bool response)
|
|
64
|
-
=> ResolveCallbackProxy(hashCode, response);
|
|
65
|
-
|
|
66
|
-
[AOT.MonoPInvokeCallback(typeof(StringResponseDelegate))]
|
|
67
|
-
private static void StringCallbackProxy(int hashCode, string response)
|
|
68
|
-
=> ResolveCallbackProxy(hashCode, response);
|
|
69
|
-
|
|
70
|
-
/*
|
|
71
|
-
* Global Callbacks
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
private static OneSignalIOS _instance;
|
|
75
|
-
|
|
76
|
-
/// <summary>
|
|
77
|
-
/// Used to provide a reference for and sets up the global callbacks
|
|
78
|
-
/// </summary>
|
|
79
|
-
public OneSignalIOS() {
|
|
80
|
-
if (_instance != null)
|
|
81
|
-
SDKDebug.Error("Additional instance of OneSignalIOS created.");
|
|
82
|
-
|
|
83
|
-
_setNotificationReceivedCallback(_onNotificationReceived);
|
|
84
|
-
_setNotificationOpenedCallback(_onNotificationOpened);
|
|
85
|
-
|
|
86
|
-
_setInAppMessageWillDisplayCallback(_onInAppMessageWillDisplay);
|
|
87
|
-
_setInAppMessageDidDisplayCallback(_onInAppMessageDidDisplay);
|
|
88
|
-
_setInAppMessageWillDismissCallback(_onInAppMessageWillDismiss);
|
|
89
|
-
_setInAppMessageDidDismissCallback(_onInAppMessageDidDismiss);
|
|
90
|
-
_setInAppMessageClickedCallback(_onInAppMessageClicked);
|
|
91
|
-
|
|
92
|
-
_setPermissionStateChangedCallback(_onPermissionStateChanged);
|
|
93
|
-
_setSubscriptionStateChangedCallback(_onSubscriptionStateChanged);
|
|
94
|
-
_setEmailSubscriptionStateChangedCallback(_onEmailSubscriptionStateChanged);
|
|
95
|
-
_setSMSSubscriptionStateChangedCallback(_onSMSSubscriptionStateChanged);
|
|
96
|
-
|
|
97
|
-
_instance = this;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/// <param name="response">OSNotification</param>
|
|
101
|
-
[AOT.MonoPInvokeCallback(typeof(NotificationWillShowInForegroundDelegate))]
|
|
102
|
-
private static bool _onNotificationReceived(string response) {
|
|
103
|
-
if (_instance.NotificationWillShow == null)
|
|
104
|
-
return true;
|
|
105
|
-
|
|
106
|
-
var notification = JsonUtility.FromJson<Notification>(response);
|
|
107
|
-
_fillNotifFromObj(ref notification, Json.Deserialize(response));
|
|
108
|
-
|
|
109
|
-
var resultNotif = _instance.NotificationWillShow(notification);
|
|
110
|
-
return resultNotif != null;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/// <param name="response">OSNotificationOpenedResult</param>
|
|
114
|
-
[AOT.MonoPInvokeCallback(typeof(StringListenerDelegate))]
|
|
115
|
-
private static void _onNotificationOpened(string response) {
|
|
116
|
-
var notifOpenResult = JsonUtility.FromJson<NotificationOpenedResult>(response);
|
|
117
|
-
|
|
118
|
-
if (Json.Deserialize(response) is Dictionary<string, object> resultDict && resultDict.ContainsKey("notification"))
|
|
119
|
-
_fillNotifFromObj(ref notifOpenResult.notification, resultDict["notification"]);
|
|
120
|
-
|
|
121
|
-
if (DidInitialize)
|
|
122
|
-
_instance.NotificationOpened?.Invoke(notifOpenResult);
|
|
123
|
-
else {
|
|
124
|
-
void invokeOpened(string appId) {
|
|
125
|
-
OnInitialize -= invokeOpened;
|
|
126
|
-
_instance.NotificationOpened?.Invoke(notifOpenResult);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
OnInitialize += invokeOpened;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
[AOT.MonoPInvokeCallback(typeof(StringListenerDelegate))]
|
|
134
|
-
private static void _onInAppMessageWillDisplay(string response)
|
|
135
|
-
=> _instance.InAppMessageWillDisplay?.Invoke(new InAppMessage { messageId = response });
|
|
136
|
-
|
|
137
|
-
[AOT.MonoPInvokeCallback(typeof(StringListenerDelegate))]
|
|
138
|
-
private static void _onInAppMessageDidDisplay(string response)
|
|
139
|
-
=> _instance.InAppMessageDidDisplay?.Invoke(new InAppMessage { messageId = response });
|
|
140
|
-
|
|
141
|
-
[AOT.MonoPInvokeCallback(typeof(StringListenerDelegate))]
|
|
142
|
-
private static void _onInAppMessageWillDismiss(string response)
|
|
143
|
-
=> _instance.InAppMessageWillDismiss?.Invoke(new InAppMessage { messageId = response });
|
|
144
|
-
|
|
145
|
-
[AOT.MonoPInvokeCallback(typeof(StringListenerDelegate))]
|
|
146
|
-
private static void _onInAppMessageDidDismiss(string response)
|
|
147
|
-
=> _instance.InAppMessageDidDismiss?.Invoke(new InAppMessage { messageId = response });
|
|
148
|
-
|
|
149
|
-
[AOT.MonoPInvokeCallback(typeof(StringListenerDelegate))]
|
|
150
|
-
private static void _onInAppMessageClicked(string response)
|
|
151
|
-
=> _instance.InAppMessageTriggeredAction?.Invoke(JsonUtility.FromJson<InAppMessageAction>(response));
|
|
152
|
-
|
|
153
|
-
[AOT.MonoPInvokeCallback(typeof(StateListenerDelegate))]
|
|
154
|
-
private static void _onPermissionStateChanged(string current, string previous) {
|
|
155
|
-
var curr = JsonUtility.FromJson<NotificationPermissionState>(current);
|
|
156
|
-
var prev = JsonUtility.FromJson<NotificationPermissionState>(previous);
|
|
157
|
-
_instance.NotificationPermissionChanged?.Invoke(curr, prev);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
[AOT.MonoPInvokeCallback(typeof(StateListenerDelegate))]
|
|
161
|
-
private static void _onSubscriptionStateChanged(string current, string previous) {
|
|
162
|
-
var curr = JsonUtility.FromJson<PushSubscriptionState>(current);
|
|
163
|
-
var prev = JsonUtility.FromJson<PushSubscriptionState>(previous);
|
|
164
|
-
_instance.PushSubscriptionStateChanged?.Invoke(curr, prev);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
[AOT.MonoPInvokeCallback(typeof(StateListenerDelegate))]
|
|
168
|
-
private static void _onEmailSubscriptionStateChanged(string current, string previous) {
|
|
169
|
-
var curr = JsonUtility.FromJson<EmailSubscriptionState>(current);
|
|
170
|
-
var prev = JsonUtility.FromJson<EmailSubscriptionState>(previous);
|
|
171
|
-
_instance.EmailSubscriptionStateChanged?.Invoke(curr, prev);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
[AOT.MonoPInvokeCallback(typeof(StateListenerDelegate))]
|
|
175
|
-
private static void _onSMSSubscriptionStateChanged(string current, string previous) {
|
|
176
|
-
var curr = JsonUtility.FromJson<SMSSubscriptionState>(current);
|
|
177
|
-
var prev = JsonUtility.FromJson<SMSSubscriptionState>(previous);
|
|
178
|
-
_instance.SMSSubscriptionStateChanged?.Invoke(curr, prev);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
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.Runtime.InteropServices;
|
|
29
|
-
|
|
30
|
-
namespace OneSignalSDK {
|
|
31
|
-
public sealed partial class OneSignalIOS : OneSignal {
|
|
32
|
-
/*
|
|
33
|
-
* Global callbacks
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
[DllImport("__Internal")] private static extern void _setNotificationReceivedCallback(NotificationWillShowInForegroundDelegate callback);
|
|
37
|
-
[DllImport("__Internal")] private static extern void _setNotificationOpenedCallback(StringListenerDelegate callback);
|
|
38
|
-
|
|
39
|
-
[DllImport("__Internal")] private static extern void _setInAppMessageWillDisplayCallback(StringListenerDelegate callback);
|
|
40
|
-
[DllImport("__Internal")] private static extern void _setInAppMessageDidDisplayCallback(StringListenerDelegate callback);
|
|
41
|
-
[DllImport("__Internal")] private static extern void _setInAppMessageWillDismissCallback(StringListenerDelegate callback);
|
|
42
|
-
[DllImport("__Internal")] private static extern void _setInAppMessageDidDismissCallback(StringListenerDelegate callback);
|
|
43
|
-
[DllImport("__Internal")] private static extern void _setInAppMessageClickedCallback(StringListenerDelegate callback);
|
|
44
|
-
|
|
45
|
-
[DllImport("__Internal")] private static extern void _setPermissionStateChangedCallback(StateListenerDelegate callback);
|
|
46
|
-
[DllImport("__Internal")] private static extern void _setSubscriptionStateChangedCallback(StateListenerDelegate callback);
|
|
47
|
-
[DllImport("__Internal")] private static extern void _setEmailSubscriptionStateChangedCallback(StateListenerDelegate callback);
|
|
48
|
-
[DllImport("__Internal")] private static extern void _setSMSSubscriptionStateChangedCallback(StateListenerDelegate callback);
|
|
49
|
-
|
|
50
|
-
/*
|
|
51
|
-
* Direct methods
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
[DllImport("__Internal")] private static extern string _getDeviceState();
|
|
55
|
-
|
|
56
|
-
[DllImport("__Internal")] private static extern void _setLogLevel(int logLevel, int alertLevel);
|
|
57
|
-
[DllImport("__Internal")] private static extern void _setPrivacyConsent(bool consent);
|
|
58
|
-
[DllImport("__Internal")] private static extern bool _getPrivacyConsent();
|
|
59
|
-
[DllImport("__Internal")] private static extern void _setRequiresPrivacyConsent(bool required);
|
|
60
|
-
[DllImport("__Internal")] private static extern bool _getRequiresPrivacyConsent();
|
|
61
|
-
[DllImport("__Internal")] private static extern void _setLaunchURLsInApp(bool launchInApp);
|
|
62
|
-
[DllImport("__Internal")] private static extern void _initialize(string appId);
|
|
63
|
-
[DllImport("__Internal")] private static extern void _promptForPushNotificationsWithUserResponse(int hashCode, BooleanResponseDelegate callback);
|
|
64
|
-
[DllImport("__Internal")] private static extern void _disablePush(bool disable);
|
|
65
|
-
[DllImport("__Internal")] private static extern void _postNotification(string optionsJson, int hashCode, StringResponseDelegate callback);
|
|
66
|
-
[DllImport("__Internal")] private static extern void _setTrigger(string key, string value);
|
|
67
|
-
[DllImport("__Internal")] private static extern void _setTriggers(string triggersJson);
|
|
68
|
-
[DllImport("__Internal")] private static extern void _removeTrigger(string key);
|
|
69
|
-
[DllImport("__Internal")] private static extern void _removeTriggers(string triggersJson);
|
|
70
|
-
[DllImport("__Internal")] private static extern string _getTrigger(string key);
|
|
71
|
-
[DllImport("__Internal")] private static extern string _getTriggers();
|
|
72
|
-
[DllImport("__Internal")] private static extern void _setInAppMessagesArePaused(bool paused);
|
|
73
|
-
[DllImport("__Internal")] private static extern bool _getInAppMessagesArePaused();
|
|
74
|
-
|
|
75
|
-
[DllImport("__Internal")] private static extern void _sendTag(string name, string value, int hashCode, BooleanResponseDelegate callback);
|
|
76
|
-
[DllImport("__Internal")] private static extern void _sendTags(string tagsJson, int hashCode, BooleanResponseDelegate callback);
|
|
77
|
-
[DllImport("__Internal")] private static extern void _getTags(int hashCode, StringResponseDelegate callback);
|
|
78
|
-
[DllImport("__Internal")] private static extern void _deleteTag(string name, int hashCode, BooleanResponseDelegate callback);
|
|
79
|
-
[DllImport("__Internal")] private static extern void _deleteTags(string tagsJson, int hashCode, BooleanResponseDelegate callback);
|
|
80
|
-
|
|
81
|
-
[DllImport("__Internal")] private static extern void _setExternalUserId(string externalId, string authHash, int hashCode, BooleanResponseDelegate callback);
|
|
82
|
-
[DllImport("__Internal")] private static extern void _setEmail(string email, string authHash, int hashCode, BooleanResponseDelegate callback);
|
|
83
|
-
[DllImport("__Internal")] private static extern void _setSMSNumber(string smsNumber, string authHash, int hashCode, BooleanResponseDelegate callback);
|
|
84
|
-
|
|
85
|
-
[DllImport("__Internal")] private static extern void _removeExternalUserId(int hashCode, BooleanResponseDelegate callback);
|
|
86
|
-
[DllImport("__Internal")] private static extern void _logoutEmail(int hashCode, BooleanResponseDelegate callback);
|
|
87
|
-
[DllImport("__Internal")] private static extern void _logoutSMSNumber(int hashCode, BooleanResponseDelegate callback);
|
|
88
|
-
|
|
89
|
-
[DllImport("__Internal")] private static extern void _setLanguage(string languageCode, int hashCode, BooleanResponseDelegate callback);
|
|
90
|
-
|
|
91
|
-
[DllImport("__Internal")] private static extern void _promptLocation();
|
|
92
|
-
[DllImport("__Internal")] private static extern void _setShareLocation(bool share);
|
|
93
|
-
[DllImport("__Internal")] private static extern bool _getShareLocation();
|
|
94
|
-
|
|
95
|
-
[DllImport("__Internal")] private static extern void _sendOutcome(string name, int hashCode, BooleanResponseDelegate callback);
|
|
96
|
-
[DllImport("__Internal")] private static extern void _sendUniqueOutcome(string name, int hashCode, BooleanResponseDelegate callback);
|
|
97
|
-
[DllImport("__Internal")] private static extern void _sendOutcomeWithValue(string name, float value, int hashCode, BooleanResponseDelegate callback);
|
|
98
|
-
|
|
99
|
-
[DllImport("__Internal")] private static extern void _enterLiveActivity(string activityId, string token, int hashCode, BooleanResponseDelegate callback);
|
|
100
|
-
[DllImport("__Internal")] private static extern void _exitLiveActivity(string activityId, int hashCode, BooleanResponseDelegate callback);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
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;
|
|
29
|
-
using System.Collections.Generic;
|
|
30
|
-
using UnityEngine;
|
|
31
|
-
|
|
32
|
-
namespace OneSignalSDK {
|
|
33
|
-
public sealed partial class OneSignalIOS : OneSignal {
|
|
34
|
-
[Serializable] private sealed class DeviceState {
|
|
35
|
-
public long notificationPermissionStatus;
|
|
36
|
-
|
|
37
|
-
public string userId;
|
|
38
|
-
public string pushToken;
|
|
39
|
-
public bool isSubscribed;
|
|
40
|
-
public bool isPushDisabled;
|
|
41
|
-
|
|
42
|
-
public string emailUserId;
|
|
43
|
-
public string emailAddress;
|
|
44
|
-
public bool isEmailSubscribed;
|
|
45
|
-
|
|
46
|
-
public string smsUserId;
|
|
47
|
-
public string smsNumber;
|
|
48
|
-
public bool isSMSSubscribed;
|
|
49
|
-
|
|
50
|
-
public static implicit operator PushSubscriptionState(DeviceState source)
|
|
51
|
-
=> new PushSubscriptionState {
|
|
52
|
-
userId = source.userId,
|
|
53
|
-
pushToken = source.pushToken,
|
|
54
|
-
isSubscribed = source.isSubscribed,
|
|
55
|
-
isPushDisabled = source.isPushDisabled,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
public static implicit operator EmailSubscriptionState(DeviceState source)
|
|
59
|
-
=> new EmailSubscriptionState {
|
|
60
|
-
emailUserId = source.emailUserId,
|
|
61
|
-
emailAddress = source.emailAddress,
|
|
62
|
-
isSubscribed = source.isEmailSubscribed,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
public static implicit operator SMSSubscriptionState(DeviceState source)
|
|
66
|
-
=> new SMSSubscriptionState {
|
|
67
|
-
smsUserId = source.smsUserId,
|
|
68
|
-
smsNumber = source.smsNumber,
|
|
69
|
-
isSubscribed = source.isSMSSubscribed,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
[Serializable] private sealed class NotificationPermissionState {
|
|
74
|
-
public long status;
|
|
75
|
-
public bool provisional;
|
|
76
|
-
public bool hasPrompted;
|
|
77
|
-
|
|
78
|
-
public static implicit operator NotificationPermission(NotificationPermissionState source)
|
|
79
|
-
=> (NotificationPermission)source.status;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private static void _fillNotifFromObj(ref Notification notif, object notifObj) {
|
|
83
|
-
if (!(notifObj is Dictionary<string, object> notifDict))
|
|
84
|
-
return;
|
|
85
|
-
|
|
86
|
-
if (notifDict.ContainsKey("additionalData"))
|
|
87
|
-
notif.additionalData = notifDict["additionalData"] as Dictionary<string, object>;
|
|
88
|
-
|
|
89
|
-
if (notifDict.ContainsKey("attachments"))
|
|
90
|
-
notif.attachments = notifDict["attachments"] as Dictionary<string, object>;
|
|
91
|
-
|
|
92
|
-
if (notifDict.ContainsKey("rawPayload") && notifDict["rawPayload"] is Dictionary<string, object> payloadDict)
|
|
93
|
-
notif.rawPayload = Json.Serialize(payloadDict);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|