Skip to content

Commit 1084c51

Browse files
authored
Merge pull request #26 from singular-labs/rc/5.4.0-kids
KIDS-SDK RC-5.4.0
2 parents d1724b5 + 4fc0199 commit 1084c51

12 files changed

+123
-25
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Singular
3+
Copyright (c) 2025 Singular
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<dependencies>
22
<androidPackages>
3-
<androidPackage spec="com.singular.sdk:singular_kids_sdk:12.6.0">
3+
<androidPackage spec="com.singular.sdk:singular_kids_sdk:12.9.0">
44
<repositories>
55
<repository>https://maven.singular.net</repository>
66
</repositories>
77
</androidPackage>
88
</androidPackages>
99
<iosPods>
10-
<iosPod name="Singular-Kids-SDK" version="12.6.0" minTargetSdk="12.0" bitcodeEnabled="false" addToAllTargets="false">
10+
<iosPod name="Singular-Kids-SDK" version="12.8.0" minTargetSdk="12.0" bitcodeEnabled="false" addToAllTargets="false">
1111
</iosPod>
1212
</iosPods>
1313
</dependencies>
17.7 KB
Binary file not shown.

SingularSDK/Plugins/Android/SingularUnityBridge.jar.meta renamed to SingularSDK/Plugins/Android/SingularUnityBridge-KIDS-6.11.0.jar.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-15.2 KB
Binary file not shown.

SingularSDK/Plugins/iOS/SingularUnityWrapper.mm

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ bool StartSingularSession_(const char* configString){
141141
withSecret:apiSecret
142142
andHandler:singularLinkHandler
143143
withTimeout:shortlinkResolveTimeout];
144-
145-
NSDictionary* globalProperties = [config objectForKey:@"globalProperties"];
146144

147145
SingularConfig* singularConfig = [[SingularConfig alloc] initWithApiKey:apiKey andSecret:apiSecret];
148146
singularConfig.shortLinkResolveTimeOut = shortlinkResolveTimeout;
@@ -161,6 +159,7 @@ bool StartSingularSession_(const char* configString){
161159
handleConversionValuesUpdated(conversionValue ? [conversionValue intValue] : -1, coarse ? [coarse intValue] : -1, lock);
162160
};
163161

162+
NSDictionary* globalProperties = [config objectForKey:@"globalProperties"];
164163
if ([globalProperties count] > 0){
165164
for (NSDictionary* property in [globalProperties allValues]) {
166165
NSString* propertyKey = [property objectForKey:@"Key"];
@@ -185,8 +184,7 @@ bool StartSingularSession_(const char* configString){
185184
singularConfig.deviceAttributionCallback = ^(NSDictionary *deviceAttributionInfo) {
186185
handleDeviceAttributionData(deviceAttributionInfo);
187186
};
188-
189-
187+
190188
NSString *customSdid = [config objectForKey:@"customSdid"];
191189
singularConfig.customSdid = customSdid;
192190

@@ -198,6 +196,16 @@ bool StartSingularSession_(const char* configString){
198196
sendSdkMessage("SingularDidSetSdid", result);
199197
};
200198

199+
NSArray *pushLinkPaths = [config objectForKey:@"pushNotificationLinkPath"];
200+
if (pushLinkPaths && pushLinkPaths.count > 0) {
201+
singularConfig.pushNotificationLinkPath = pushLinkPaths;
202+
}
203+
204+
NSArray *brandedDomains = [config objectForKey:@"brandedDomains"];
205+
if (brandedDomains && brandedDomains.count > 0) {
206+
singularConfig.brandedDomains = brandedDomains;
207+
}
208+
201209
[Singular start:singularConfig];
202210

203211
return true;
@@ -331,6 +339,16 @@ void SetAllowAutoIAPComplete_(bool allowed){
331339
[Singular setAllowAutoIAPComplete:b];
332340
}
333341

342+
void HandlePushNotification_(const char* payloadJson) {
343+
NSError *error;
344+
NSDictionary *pushPayloadDictionary = [NSJSONSerialization JSONObjectWithData:[[NSString stringWithUTF8String:payloadJson]
345+
dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error];
346+
if (error) { return; }
347+
if (pushPayloadDictionary.allKeys.count == 0) { return; }
348+
349+
[Singular handlePushNotification:pushPayloadDictionary];
350+
}
351+
334352
void SetBatchesEvents_(bool setBatches){
335353
BOOL b = setBatches ? YES : NO;
336354
[Singular setBatchesEvents:b];
@@ -475,7 +493,7 @@ void LimitDataSharing_(bool limitDataSharingValue) {
475493
bool GetLimitDataSharing_() {
476494
return [Singular getLimitDataSharing];
477495
}
478-
496+
479497
/* Global Properties */
480498

481499
const char* GetGlobalProperties_() {

SingularSDK/Runtime/SingularSDK.asmdef

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"precompiledReferences": [],
1212
"autoReferenced": true,
1313
"defineConstraints": [],
14-
"versionDefines": [],
14+
"versionDefines": [
15+
{
16+
"name": "com.unity.purchasing",
17+
"expression": "",
18+
"define": "SINGULAR_SDK_IAP_ENABLED"
19+
}
20+
],
1521
"noEngineReferences": false
1622
}

SingularSDK/Runtime/SingularSDK.cs

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class SingularSDK : MonoBehaviour
1818
{
1919
#region SDK properties
2020

21-
// init:
21+
#region init properties
2222
public string SingularAPIKey = "<YourAPIKey>";
2323
public string SingularAPISecret = "<YourAPISecret>";
2424
public bool InitializeOnAwake = true;
@@ -30,7 +30,7 @@ public class SingularSDK : MonoBehaviour
3030
public static bool Initialized { get; private set; } = false;
3131

3232
private const string UNITY_WRAPPER_NAME = "Unity";
33-
private const string UNITY_VERSION = "5.3.0-KIDS";
33+
private const string UNITY_VERSION = "5.4.0-KIDS";
3434

3535
// ios-only:
3636
[Obsolete]
@@ -39,12 +39,12 @@ public class SingularSDK : MonoBehaviour
3939
public bool SKANEnabled = true;
4040
public bool manualSKANConversionManagement = false;
4141
public int waitForTrackingAuthorizationWithTimeoutInterval = 0;
42+
#endregion // iOS-only
4243

43-
// android-only:
44+
#region Android-only
4445
public static string fcmDeviceToken = null;
4546
public string facebookAppId;
4647
public bool collectOAID = false;
47-
public bool limitedIdentifiersEnabled = false;
4848

4949
private static string imei;
5050
#if UNITY_ANDROID
@@ -55,13 +55,14 @@ public class SingularSDK : MonoBehaviour
5555

5656
static bool status = false;
5757
#endif
58+
#endregion //Android-only
5859

59-
// cross-os:
60+
#region Cross-platform
6061
private Dictionary<string, SingularGlobalProperty> globalProperties = new Dictionary<string, SingularGlobalProperty>();
6162
private static bool? limitDataSharing = null;
6263
private static string customUserId;
6364

64-
// deep links:
65+
#region Deeplinks
6566
public long ddlTimeoutSec = 0; // default value (0) sets to default timeout (60s)
6667
public long sessionTimeoutSec = 0; // default value (0) sets to default timeout (60s)
6768
public long shortlinkResolveTimeout = 0; // default value (0) sets to default timeout (10s)
@@ -75,27 +76,42 @@ public class SingularSDK : MonoBehaviour
7576
private Int32 resolvedSingularLinkTime;
7677
static Int32 cachedDDLMessageTime;
7778
static string cachedDDLMessage;
79+
#endregion // Deeplinks
7880

79-
// session management:
81+
#region Session management
8082
public static bool endSessionOnGoingToBackground = false;
8183
public static bool restartSessionOnReturningToForeground = false;
84+
#endregion // Session management
8285

83-
// admon/batching:
86+
#region Admom/batching
8487
public static bool batchEvents = false;
8588
private const string ADMON_REVENUE_EVENT_NAME = "__ADMON_USER_LEVEL_REVENUE__";
89+
#endregion // Admon/batching
8690

87-
// SDID:
91+
#region SDID
8892
public static string CustomSdid;
93+
#endregion // SDID
94+
95+
#region Push Notifications
96+
public string[] pushNotificationsLinkPaths;
97+
#endregion // Push Notifications
98+
99+
#region Branded Domains
100+
public string[] brandedDomains;
101+
#endregion // Branded Domains
89102

90-
// handlers and callbacks:
103+
#region Handlers and Callbacks
91104
public static SingularLinkHandler registeredSingularLinkHandler = null;
92105
public static SingularDeferredDeepLinkHandler registeredDDLHandler = null;
93106
public static SingularConversionValueUpdatedHandler registeredConversionValueUpdatedHandler = null;
94107
public static SingularConversionValuesUpdatedHandler registeredConversionValuesUpdatedHandler = null;
95108
public static SingularDeviceAttributionCallbackHandler registeredDeviceAttributionCallbackHandler = null;
96109
public static SingularSdidAccessorHandler registeredSdidAccessorHandler = null;
110+
#endregion // Handlers and Callbacks
97111

98-
#endregion
112+
#endregion // Cross-platform
113+
114+
#endregion // SDK properties
99115

100116
// The Singular SDK is initialized here
101117
void Awake()
@@ -178,6 +194,8 @@ private static SingularConfig BuildSingularConfig()
178194
config.SetValue("globalProperties", instance.globalProperties);
179195
config.SetValue("sessionTimeoutSec", instance.sessionTimeoutSec);
180196
config.SetValue("customSdid", CustomSdid);
197+
config.SetValue("pushNotificationLinkPath", Utilities.DelimitedStringsArrayToArrayOfArrayOfString(instance.pushNotificationsLinkPaths, '/'));
198+
config.SetValue("brandedDomains", instance.brandedDomains);
181199
#if UNITY_ANDROID
182200
config.SetValue("facebookAppId", instance.facebookAppId);
183201
config.SetValue("customUserId", customUserId);
@@ -187,13 +205,14 @@ private static SingularConfig BuildSingularConfig()
187205
config.SetValue("enableDeferredDeepLinks", enableDeferredDeepLinks);
188206
config.SetValue("enableLogging", instance.enableLogging);
189207
config.SetValue("logLevel", instance.logLevel);
190-
if (SingularSDK.fcmDeviceToken != null){
208+
if (SingularSDK.fcmDeviceToken != null)
209+
{
191210
config.SetValue("fcmDeviceToken", SingularSDK.fcmDeviceToken);
192211
}
193212
config.SetValue("collectOAID", instance.collectOAID);
194-
config.SetValue("limitedIdentifiersEnabled", instance.limitedIdentifiersEnabled);
195213

196-
if (limitDataSharing != null) {
214+
if (limitDataSharing != null)
215+
{
197216
config.SetValue("limitDataSharing", limitDataSharing);
198217
}
199218

@@ -296,6 +315,9 @@ private enum NSType
296315
[DllImport("__Internal")]
297316
private static extern void SetAllowAutoIAPComplete_(bool allowed);
298317

318+
[DllImport("__Internal")]
319+
private static extern void HandlePushNotification_(string payloadJson);
320+
299321
[DllImport("__Internal")]
300322
private static extern void SetBatchesEvents_(bool allowed);
301323

@@ -838,6 +860,33 @@ public static void SetAllowAutoIAPComplete(bool allowed)
838860
#endif
839861
}
840862

863+
#region Push Notifications
864+
public static void HandlePushNotification(Dictionary<string, string> pushNotificationPayload)
865+
{
866+
if (Application.isEditor ||
867+
!Initialized ||
868+
!instance)
869+
{
870+
SingularUnityLogger.LogDebug("HandlePushNotification called before Singular SDK initialized. ignoring.");
871+
return;
872+
}
873+
874+
if (pushNotificationPayload == null)
875+
{
876+
SingularUnityLogger.LogDebug("HandlePushNotification called with null. ignoring.");
877+
return;
878+
}
879+
880+
string payloadAsJsonString = JsonConvert.SerializeObject(pushNotificationPayload);
881+
#if UNITY_IOS
882+
HandlePushNotification_(payloadAsJsonString);
883+
#elif UNITY_ANDROID
884+
SingularUnityLogger.LogDebug("SingularSDK HandlePushNotification is an iOS-only API which is not availalbe for Android. skipping.");
885+
#endif
886+
}
887+
888+
#endregion // Push Notifications
889+
841890
void OnApplicationPause(bool paused)
842891
{
843892
if (!Initialized || !instance)

SingularSDK/Runtime/Utilities.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace Singular
2+
{
3+
public class Utilities
4+
{
5+
public static string[][] DelimitedStringsArrayToArrayOfArrayOfString(string[] delimitedStringsArray, char delimiter)
6+
{
7+
if (delimitedStringsArray == null || delimitedStringsArray.Length == 0)
8+
{
9+
SingularUnityLogger.LogDebug("push notification paths strings array is null or empty. skipping.");
10+
return null;
11+
}
12+
13+
string[][] arrayOfArrayOfString = new string[delimitedStringsArray.Length][];
14+
for (int i = 0; i < delimitedStringsArray.Length; i++)
15+
{
16+
arrayOfArrayOfString[i] = delimitedStringsArray[i].Split(delimiter);
17+
}
18+
19+
return arrayOfArrayOfString;
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)