@@ -8,7 +8,7 @@ namespace AdjustSdk
8
8
#if UNITY_IOS
9
9
public class AdjustiOS
10
10
{
11
- private const string sdkPrefix = "unity5.4.1 " ;
11
+ private const string sdkPrefix = "unity5.4.2 " ;
12
12
13
13
// app callbacks as method parameters
14
14
private static List < Action < bool > > appIsEnabledGetterCallbacks ;
@@ -19,8 +19,10 @@ public class AdjustiOS
19
19
private static List < Action < string > > appLastDeeplinkGetterCallbacks ;
20
20
private static List < Action < string > > appSdkVersionGetterCallbacks ;
21
21
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 ;
24
26
private static Action < string > appResolvedDeeplinkCallback ;
25
27
private static Action < string > appSkanErrorCallback ;
26
28
@@ -61,6 +63,7 @@ private static extern void _AdjustInitSdk(
61
63
int isSendingInBackgroundEnabled ,
62
64
int isAdServicesEnabled ,
63
65
int isIdfaReadingEnabled ,
66
+ int isIdfvReadingEnabled ,
64
67
int isSkanAttributionEnabled ,
65
68
int isLinkMeEnabled ,
66
69
int isCostDataInAttributionEnabled ,
@@ -228,14 +231,15 @@ private static extern void _AdjustUpdateSkanConversionValue(
228
231
[ DllImport ( "__Internal" ) ]
229
232
private static extern void _AdjustTrackSubsessionEnd ( ) ;
230
233
231
- private delegate void AdjustDelegatePurchaseVerificationCallback ( string verificationResult ) ;
234
+ private delegate void AdjustDelegatePurchaseVerificationCallback ( string verificationResult , int callbackId ) ;
232
235
[ DllImport ( "__Internal" ) ]
233
236
private static extern void _AdjustVerifyAppStorePurchase (
234
237
string transactionId ,
235
238
string productId ,
239
+ int callbackId ,
236
240
AdjustDelegatePurchaseVerificationCallback callback ) ;
237
241
238
- private delegate void AdjustDelegateVerifyAndTrackCallback ( string verificationResult ) ;
242
+ private delegate void AdjustDelegateVerifyAndTrackCallback ( string verificationResult , int callbackId ) ;
239
243
[ DllImport ( "__Internal" ) ]
240
244
private static extern void _AdjustVerifyAndTrackAppStorePurchase (
241
245
string eventToken ,
@@ -247,7 +251,8 @@ private static extern void _AdjustVerifyAndTrackAppStorePurchase(
247
251
string deduplicationId ,
248
252
string jsonCallbackParameters ,
249
253
string jsonPartnerParameters ,
250
- AdjustDelegatePurchaseVerificationCallback callback ) ;
254
+ int verificationCallbackId ,
255
+ AdjustDelegateVerifyAndTrackCallback callback ) ;
251
256
252
257
[ DllImport ( "__Internal" ) ]
253
258
private static extern void _AdjustEndFirstSessionDelay ( ) ;
@@ -286,6 +291,7 @@ public static void InitSdk(AdjustConfig adjustConfig)
286
291
int isSendingInBackgroundEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsSendingInBackgroundEnabled ) ;
287
292
int isAdServicesEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsAdServicesEnabled ) ;
288
293
int isIdfaReadingEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsIdfaReadingEnabled ) ;
294
+ int isIdfvReadingEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsIdfvReadingEnabled ) ;
289
295
int allowSuppressLogLevel = AdjustUtils . ConvertBool ( adjustConfig . AllowSuppressLogLevel ) ;
290
296
int isDeferredDeeplinkOpeningEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsDeferredDeeplinkOpeningEnabled ) ;
291
297
int isSkanAttributionEnabled = AdjustUtils . ConvertBool ( adjustConfig . IsSkanAttributionEnabled ) ;
@@ -323,6 +329,7 @@ public static void InitSdk(AdjustConfig adjustConfig)
323
329
isSendingInBackgroundEnabled ,
324
330
isAdServicesEnabled ,
325
331
isIdfaReadingEnabled ,
332
+ isIdfvReadingEnabled ,
326
333
isSkanAttributionEnabled ,
327
334
isLinkMeEnabled ,
328
335
isCostDataInAttributionEnabled ,
@@ -595,11 +602,19 @@ public static void VerifyAppStorePurchase(
595
602
{
596
603
string transactionId = purchase . TransactionId ;
597
604
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 ;
599
613
600
614
_AdjustVerifyAppStorePurchase (
601
615
transactionId ,
602
616
productId ,
617
+ callbackId ,
603
618
PurchaseVerificationCallbackMonoPInvoke ) ;
604
619
}
605
620
@@ -622,7 +637,14 @@ public static void VerifyAndTrackAppStorePurchase(
622
637
string deduplicationId = adjustEvent . DeduplicationId ;
623
638
string stringJsonCallbackParameters = AdjustUtils . ConvertReadOnlyCollectionOfPairsToJson ( adjustEvent . CallbackParameters ) ;
624
639
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 ;
626
648
627
649
_AdjustVerifyAndTrackAppStorePurchase (
628
650
eventToken ,
@@ -634,6 +656,7 @@ public static void VerifyAndTrackAppStorePurchase(
634
656
deduplicationId ,
635
657
stringJsonCallbackParameters ,
636
658
stringJsonPartnerParameters ,
659
+ verificationCallbackId ,
637
660
VerifyAndTrackCallbackMonoPInvoke ) ;
638
661
}
639
662
@@ -911,37 +934,47 @@ private static void AttCallbackMonoPInvoke(int status)
911
934
}
912
935
913
936
[ AOT . MonoPInvokeCallback ( typeof ( AdjustDelegatePurchaseVerificationCallback ) ) ]
914
- private static void PurchaseVerificationCallbackMonoPInvoke ( string verificationResult )
937
+ private static void PurchaseVerificationCallbackMonoPInvoke ( string verificationResult , int callbackId )
915
938
{
916
- if ( appPurchaseVerificationCallback == null )
939
+ if ( appPurchaseVerificationCallbacks == null || ! appPurchaseVerificationCallbacks . ContainsKey ( callbackId ) )
917
940
{
918
941
return ;
919
942
}
920
943
921
944
AdjustThreadDispatcher . RunOnMainThread ( ( ) =>
922
945
{
923
- if ( appPurchaseVerificationCallback != null )
946
+ if ( appPurchaseVerificationCallbacks != null && appPurchaseVerificationCallbacks . ContainsKey ( callbackId ) )
924
947
{
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
+ }
927
955
}
928
956
} ) ;
929
957
}
930
958
931
959
[ AOT . MonoPInvokeCallback ( typeof ( AdjustDelegateVerifyAndTrackCallback ) ) ]
932
- private static void VerifyAndTrackCallbackMonoPInvoke ( string verificationResult )
960
+ private static void VerifyAndTrackCallbackMonoPInvoke ( string verificationResult , int callbackId )
933
961
{
934
- if ( appVerifyAndTrackCallback == null )
962
+ if ( appVerifyAndTrackCallbacks == null || ! appVerifyAndTrackCallbacks . ContainsKey ( callbackId ) )
935
963
{
936
964
return ;
937
965
}
938
966
939
967
AdjustThreadDispatcher . RunOnMainThread ( ( ) =>
940
968
{
941
- if ( appVerifyAndTrackCallback != null )
969
+ if ( appVerifyAndTrackCallbacks != null && appVerifyAndTrackCallbacks . ContainsKey ( callbackId ) )
942
970
{
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
+ }
945
978
}
946
979
} ) ;
947
980
}
0 commit comments