@@ -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 )
0 commit comments