@@ -8,7 +8,7 @@ namespace AdjustSdk
88#if UNITY_IOS
99 public class AdjustiOS
1010 {
11- private const string sdkPrefix = "unity5.4.1 " ;
11+ private const string sdkPrefix = "unity5.4.2 " ;
1212
1313 // app callbacks as method parameters
1414 private static List < Action < bool > > appIsEnabledGetterCallbacks ;
@@ -19,8 +19,10 @@ public class AdjustiOS
1919 private static List < Action < string > > appLastDeeplinkGetterCallbacks ;
2020 private static List < Action < string > > appSdkVersionGetterCallbacks ;
2121 private static List < Action < int > > appAttCallbacks ;
22- private static Action < AdjustPurchaseVerificationResult > appPurchaseVerificationCallback ;
23- private static Action < AdjustPurchaseVerificationResult > appVerifyAndTrackCallback ;
22+ private static Dictionary < int , Action < AdjustPurchaseVerificationResult > > appPurchaseVerificationCallbacks ;
23+ private static Dictionary < int , Action < AdjustPurchaseVerificationResult > > appVerifyAndTrackCallbacks ;
24+ private static int nextPurchaseVerificationCallbackId = 0 ;
25+ private static int nextVerifyAndTrackCallbackId = 0 ;
2426 private static Action < string > appResolvedDeeplinkCallback ;
2527 private static Action < string > appSkanErrorCallback ;
2628
@@ -61,6 +63,7 @@ private static extern void _AdjustInitSdk(
6163 int isSendingInBackgroundEnabled ,
6264 int isAdServicesEnabled ,
6365 int isIdfaReadingEnabled ,
66+ int isIdfvReadingEnabled ,
6467 int isSkanAttributionEnabled ,
6568 int isLinkMeEnabled ,
6669 int isCostDataInAttributionEnabled ,
@@ -228,14 +231,15 @@ private static extern void _AdjustUpdateSkanConversionValue(
228231 [ DllImport ( "__Internal" ) ]
229232 private static extern void _AdjustTrackSubsessionEnd ( ) ;
230233
231- private delegate void AdjustDelegatePurchaseVerificationCallback ( string verificationResult ) ;
234+ private delegate void AdjustDelegatePurchaseVerificationCallback ( string verificationResult , int callbackId ) ;
232235 [ DllImport ( "__Internal" ) ]
233236 private static extern void _AdjustVerifyAppStorePurchase (
234237 string transactionId ,
235238 string productId ,
239+ int callbackId ,
236240 AdjustDelegatePurchaseVerificationCallback callback ) ;
237241
238- private delegate void AdjustDelegateVerifyAndTrackCallback ( string verificationResult ) ;
242+ private delegate void AdjustDelegateVerifyAndTrackCallback ( string verificationResult , int callbackId ) ;
239243 [ DllImport ( "__Internal" ) ]
240244 private static extern void _AdjustVerifyAndTrackAppStorePurchase (
241245 string eventToken ,
@@ -247,7 +251,8 @@ private static extern void _AdjustVerifyAndTrackAppStorePurchase(
247251 string deduplicationId ,
248252 string jsonCallbackParameters ,
249253 string jsonPartnerParameters ,
250- AdjustDelegatePurchaseVerificationCallback callback ) ;
254+ int verificationCallbackId ,
255+ AdjustDelegateVerifyAndTrackCallback callback ) ;
251256
252257 [ DllImport ( "__Internal" ) ]
253258 private static extern void _AdjustEndFirstSessionDelay ( ) ;
@@ -286,6 +291,7 @@ public static void InitSdk(AdjustConfig adjustConfig)
286291 int isSendingInBackgroundEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsSendingInBackgroundEnabled ) ;
287292 int isAdServicesEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsAdServicesEnabled ) ;
288293 int isIdfaReadingEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsIdfaReadingEnabled ) ;
294+ int isIdfvReadingEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsIdfvReadingEnabled ) ;
289295 int allowSuppressLogLevel = AdjustUtils . ConvertBool ( adjustConfig . AllowSuppressLogLevel ) ;
290296 int isDeferredDeeplinkOpeningEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsDeferredDeeplinkOpeningEnabled ) ;
291297 int isSkanAttributionEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsSkanAttributionEnabled ) ;
@@ -323,6 +329,7 @@ public static void InitSdk(AdjustConfig adjustConfig)
323329 isSendingInBackgroundEnabled ,
324330 isAdServicesEnabled ,
325331 isIdfaReadingEnabled ,
332+ isIdfvReadingEnabled ,
326333 isSkanAttributionEnabled ,
327334 isLinkMeEnabled ,
328335 isCostDataInAttributionEnabled ,
@@ -595,11 +602,19 @@ public static void VerifyAppStorePurchase(
595602 {
596603 string transactionId = purchase . TransactionId ;
597604 string productId = purchase . ProductId ;
598- appPurchaseVerificationCallback = callback ;
605+
606+ if ( appPurchaseVerificationCallbacks == null )
607+ {
608+ appPurchaseVerificationCallbacks = new Dictionary < int , Action < AdjustPurchaseVerificationResult > > ( ) ;
609+ }
610+
611+ int callbackId = ++ nextPurchaseVerificationCallbackId ;
612+ appPurchaseVerificationCallbacks [ callbackId ] = callback ;
599613
600614 _AdjustVerifyAppStorePurchase (
601615 transactionId ,
602616 productId ,
617+ callbackId ,
603618 PurchaseVerificationCallbackMonoPInvoke ) ;
604619 }
605620
@@ -622,7 +637,14 @@ public static void VerifyAndTrackAppStorePurchase(
622637 string deduplicationId = adjustEvent . DeduplicationId ;
623638 string stringJsonCallbackParameters = AdjustUtils . ConvertReadOnlyCollectionOfPairsToJson ( adjustEvent . CallbackParameters ) ;
624639 string stringJsonPartnerParameters = AdjustUtils . ConvertReadOnlyCollectionOfPairsToJson ( adjustEvent . PartnerParameters ) ;
625- appVerifyAndTrackCallback = callback ;
640+
641+ if ( appVerifyAndTrackCallbacks == null )
642+ {
643+ appVerifyAndTrackCallbacks = new Dictionary < int , Action < AdjustPurchaseVerificationResult > > ( ) ;
644+ }
645+
646+ int verificationCallbackId = ++ nextVerifyAndTrackCallbackId ;
647+ appVerifyAndTrackCallbacks [ verificationCallbackId ] = callback ;
626648
627649 _AdjustVerifyAndTrackAppStorePurchase (
628650 eventToken ,
@@ -634,6 +656,7 @@ public static void VerifyAndTrackAppStorePurchase(
634656 deduplicationId ,
635657 stringJsonCallbackParameters ,
636658 stringJsonPartnerParameters ,
659+ verificationCallbackId ,
637660 VerifyAndTrackCallbackMonoPInvoke ) ;
638661 }
639662
@@ -911,37 +934,47 @@ private static void AttCallbackMonoPInvoke(int status)
911934 }
912935
913936 [ AOT . MonoPInvokeCallback ( typeof ( AdjustDelegatePurchaseVerificationCallback ) ) ]
914- private static void PurchaseVerificationCallbackMonoPInvoke ( string verificationResult )
937+ private static void PurchaseVerificationCallbackMonoPInvoke ( string verificationResult , int callbackId )
915938 {
916- if ( appPurchaseVerificationCallback == null )
939+ if ( appPurchaseVerificationCallbacks == null || ! appPurchaseVerificationCallbacks . ContainsKey ( callbackId ) )
917940 {
918941 return ;
919942 }
920943
921944 AdjustThreadDispatcher . RunOnMainThread ( ( ) =>
922945 {
923- if ( appPurchaseVerificationCallback != null )
946+ if ( appPurchaseVerificationCallbacks != null && appPurchaseVerificationCallbacks . ContainsKey ( callbackId ) )
924947 {
925- appPurchaseVerificationCallback . Invoke ( new AdjustPurchaseVerificationResult ( verificationResult ) ) ;
926- appPurchaseVerificationCallback = null ;
948+ Action < AdjustPurchaseVerificationResult > callback = appPurchaseVerificationCallbacks [ callbackId ] ;
949+ appPurchaseVerificationCallbacks . Remove ( callbackId ) ;
950+
951+ if ( callback != null )
952+ {
953+ callback . Invoke ( new AdjustPurchaseVerificationResult ( verificationResult ) ) ;
954+ }
927955 }
928956 } ) ;
929957 }
930958
931959 [ AOT . MonoPInvokeCallback ( typeof ( AdjustDelegateVerifyAndTrackCallback ) ) ]
932- private static void VerifyAndTrackCallbackMonoPInvoke ( string verificationResult )
960+ private static void VerifyAndTrackCallbackMonoPInvoke ( string verificationResult , int callbackId )
933961 {
934- if ( appVerifyAndTrackCallback == null )
962+ if ( appVerifyAndTrackCallbacks == null || ! appVerifyAndTrackCallbacks . ContainsKey ( callbackId ) )
935963 {
936964 return ;
937965 }
938966
939967 AdjustThreadDispatcher . RunOnMainThread ( ( ) =>
940968 {
941- if ( appVerifyAndTrackCallback != null )
969+ if ( appVerifyAndTrackCallbacks != null && appVerifyAndTrackCallbacks . ContainsKey ( callbackId ) )
942970 {
943- appVerifyAndTrackCallback . Invoke ( new AdjustPurchaseVerificationResult ( verificationResult ) ) ;
944- appVerifyAndTrackCallback = null ;
971+ Action < AdjustPurchaseVerificationResult > callback = appVerifyAndTrackCallbacks [ callbackId ] ;
972+ appVerifyAndTrackCallbacks . Remove ( callbackId ) ;
973+
974+ if ( callback != null )
975+ {
976+ callback . Invoke ( new AdjustPurchaseVerificationResult ( verificationResult ) ) ;
977+ }
945978 }
946979 } ) ;
947980 }
0 commit comments