@@ -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,17 +30,20 @@ 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.2 " ;
33+ private const string UNITY_VERSION = "5.4.0 " ;
3434
35- // ios-only:
35+ #endregion // init properties
36+
37+ #region iOS-only
3638 [ Obsolete ]
3739 public bool autoIAPComplete = false ;
3840 public bool clipboardAttribution = false ;
3941 public bool SKANEnabled = true ;
4042 public bool manualSKANConversionManagement = false ;
4143 public int waitForTrackingAuthorizationWithTimeoutInterval = 0 ;
44+ #endregion // iOS-only
4245
43- // android -only:
46+ #region Android -only
4447 public static string fcmDeviceToken = null ;
4548 public string facebookAppId ;
4649 public bool collectOAID = false ;
@@ -54,14 +57,15 @@ public class SingularSDK : MonoBehaviour
5457
5558 static bool status = false ;
5659 #endif
60+ #endregion //Android-only
5761
58- // cross-os:
62+ #region Cross-platform
5963 private Dictionary < string , SingularGlobalProperty > globalProperties = new Dictionary < string , SingularGlobalProperty > ( ) ;
6064 private static bool ? limitDataSharing = null ;
6165 private static string customUserId ;
62- public bool limitedIdentifiersEnabled = false ;
66+ public bool limitAdvertisingIdentifiers = false ;
6367
64- // deep links:
68+ #region Deeplinks
6569 public long ddlTimeoutSec = 0 ; // default value (0) sets to default timeout (60s)
6670 public long sessionTimeoutSec = 0 ; // default value (0) sets to default timeout (60s)
6771 public long shortlinkResolveTimeout = 0 ; // default value (0) sets to default timeout (10s)
@@ -75,27 +79,42 @@ public class SingularSDK : MonoBehaviour
7579 private Int32 resolvedSingularLinkTime ;
7680 static Int32 cachedDDLMessageTime ;
7781 static string cachedDDLMessage ;
82+ #endregion // Deeplinks
7883
79- // session management:
84+ #region Session management
8085 public static bool endSessionOnGoingToBackground = false ;
8186 public static bool restartSessionOnReturningToForeground = false ;
87+ #endregion // Session management
8288
83- // admon /batching:
89+ #region Admom /batching
8490 public static bool batchEvents = false ;
8591 private const string ADMON_REVENUE_EVENT_NAME = "__ADMON_USER_LEVEL_REVENUE__" ;
92+ #endregion // Admon/batching
8693
87- // SDID:
94+ #region SDID
8895 public static string CustomSdid ;
96+ #endregion // SDID
97+
98+ #region Push Notifications
99+ public string [ ] pushNotificationsLinkPaths ;
100+ #endregion // Push Notifications
101+
102+ #region Branded Domains
103+ public string [ ] brandedDomains ;
104+ #endregion // Branded Domains
89105
90- // handlers and callbacks:
106+ #region Handlers and Callbacks
91107 public static SingularLinkHandler registeredSingularLinkHandler = null ;
92108 public static SingularDeferredDeepLinkHandler registeredDDLHandler = null ;
93109 public static SingularConversionValueUpdatedHandler registeredConversionValueUpdatedHandler = null ;
94110 public static SingularConversionValuesUpdatedHandler registeredConversionValuesUpdatedHandler = null ;
95111 public static SingularDeviceAttributionCallbackHandler registeredDeviceAttributionCallbackHandler = null ;
96112 public static SingularSdidAccessorHandler registeredSdidAccessorHandler = null ;
113+ #endregion // Handlers and Callbacks
97114
98- #endregion
115+ #endregion // Cross-platform
116+
117+ #endregion // SDK properties
99118
100119 // The Singular SDK is initialized here
101120 void Awake ( )
@@ -178,7 +197,9 @@ private static SingularConfig BuildSingularConfig()
178197 config . SetValue ( "globalProperties" , instance . globalProperties ) ;
179198 config . SetValue ( "sessionTimeoutSec" , instance . sessionTimeoutSec ) ;
180199 config . SetValue ( "customSdid" , CustomSdid ) ;
181- config . SetValue ( "limitedIdentifiersEnabled" , instance . limitedIdentifiersEnabled ) ;
200+ config . SetValue ( "pushNotificationLinkPath" , Utilities . DelimitedStringsArrayToArrayOfArrayOfString ( instance . pushNotificationsLinkPaths , '/' ) ) ;
201+ config . SetValue ( "limitAdvertisingIdentifiers" , instance . limitAdvertisingIdentifiers ) ;
202+ config . SetValue ( "brandedDomains" , instance . brandedDomains ) ;
182203#if UNITY_ANDROID
183204 config . SetValue ( "facebookAppId" , instance . facebookAppId ) ;
184205 config . SetValue ( "customUserId" , customUserId ) ;
@@ -298,6 +319,9 @@ private enum NSType
298319 [ DllImport ( "__Internal" ) ]
299320 private static extern void SetAllowAutoIAPComplete_ ( bool allowed ) ;
300321
322+ [ DllImport ( "__Internal" ) ]
323+ private static extern void HandlePushNotification_ ( string payloadJson ) ;
324+
301325 [ DllImport ( "__Internal" ) ]
302326 private static extern void SetBatchesEvents_ ( bool allowed ) ;
303327
@@ -425,6 +449,9 @@ private enum NSType
425449 [ DllImport ( "__Internal" ) ]
426450 private static extern bool GetLimitDataSharing_ ( ) ;
427451
452+ [ DllImport ( "__Internal" ) ]
453+ private static extern void SetLimitAdvertisingIdentifiers_ ( bool isEnabled ) ;
454+
428455 [ DllImport ( "__Internal" ) ]
429456 private static extern void SkanRegisterAppForAdNetworkAttribution_ ( ) ;
430457
@@ -843,6 +870,33 @@ public static void SetAllowAutoIAPComplete(bool allowed)
843870#endif
844871 }
845872
873+ #region Push Notifications
874+ public static void HandlePushNotification ( Dictionary < string , string > pushNotificationPayload )
875+ {
876+ if ( Application . isEditor ||
877+ ! Initialized ||
878+ ! instance )
879+ {
880+ SingularUnityLogger . LogDebug ( "HandlePushNotification called before Singular SDK initialized. ignoring." ) ;
881+ return ;
882+ }
883+
884+ if ( pushNotificationPayload == null )
885+ {
886+ SingularUnityLogger . LogDebug ( "HandlePushNotification called with null. ignoring." ) ;
887+ return ;
888+ }
889+
890+ string payloadAsJsonString = JsonConvert . SerializeObject ( pushNotificationPayload ) ;
891+ #if UNITY_IOS
892+ HandlePushNotification_ ( payloadAsJsonString ) ;
893+ #elif UNITY_ANDROID
894+ SingularUnityLogger . LogDebug ( "SingularSDK HandlePushNotification is an iOS-only API which is not availalbe for Android. skipping." ) ;
895+ #endif
896+ }
897+
898+ #endregion // Push Notifications
899+
846900 void OnApplicationPause ( bool paused )
847901 {
848902 if ( ! Initialized || ! instance )
@@ -1657,6 +1711,23 @@ public static bool GetLimitDataSharing()
16571711
16581712 return false ;
16591713 }
1714+
1715+ public static void SetLimitAdvertisingIdentifiers ( bool isEnabled )
1716+ {
1717+ if ( Application . isEditor )
1718+ {
1719+ return ;
1720+ }
1721+ #if UNITY_IOS
1722+ SetLimitAdvertisingIdentifiers_ ( isEnabled ) ;
1723+ #elif UNITY_ANDROID
1724+ if ( singular != null )
1725+ {
1726+ singular . CallStatic ( "setLimitAdvertisingIdentifiers" , isEnabled ) ;
1727+ }
1728+ #endif
1729+ }
1730+
16601731
16611732 public static void AdRevenue ( SingularAdData adData )
16621733 {
0 commit comments