@@ -476,7 +476,7 @@ -(void) handleCallback:(NSDictionary *) message {
476476}
477477
478478- (NSArray <NSString *> *)supportedEvents {
479- return @[afOnAttributionFailure,afOnAppOpenAttribution,afOnInstallConversionFailure, afOnInstallConversionDataLoaded, afOnDeepLinking];
479+ return @[afOnAttributionFailure,afOnAppOpenAttribution,afOnInstallConversionFailure, afOnInstallConversionDataLoaded, afOnDeepLinking, afOnValidationResult ];
480480}
481481
482482-(void ) reportOnFailure : (NSString *)errorMessage type : (NSString *) type {
@@ -608,7 +608,7 @@ - (BOOL)isExpoApp {
608608 additionalParameters:(NSDictionary *)additionalParameters) {
609609
610610 if (!purchaseDetails || [purchaseDetails isKindOfClass: [NSNull class ]]) {
611- [self sendEventWithName: @" onValidationResult " body: @" {\" error\" : \" Purchase details are required\" }" ];
611+ [self sendEventWithName: afOnValidationResult body: @" {\" error\" : \" Purchase details are required\" }" ];
612612 return ;
613613 }
614614
@@ -617,7 +617,7 @@ - (BOOL)isExpoApp {
617617 NSString * transactionId = [purchaseDetails objectForKey: @" transactionId" ];
618618
619619 if (!purchaseType || !productId || !transactionId) {
620- [self sendEventWithName: @" onValidationResult " body: @" {\" error\" : \" purchaseType, productId, and transactionId are required\" }" ];
620+ [self sendEventWithName: afOnValidationResult body: @" {\" error\" : \" purchaseType, productId, and transactionId are required\" }" ];
621621 return ;
622622 }
623623
@@ -629,20 +629,21 @@ - (BOOL)isExpoApp {
629629 afPurchaseType = AFSDKPurchaseTypeOneTimePurchase;
630630 }
631631
632- // Create AFSDKPurchaseDetails object
633- AFSDKPurchaseDetails* details = [[AFSDKPurchaseDetails alloc ] initWithPurchaseType: afPurchaseType
634- productId: productId
635- transactionId: transactionId];
636-
637- [[AppsFlyerLib shared ] validateAndLogInAppPurchase: details
638- extraEventValues: additionalParameters
639- completionHandler: ^(AFSDKValidateAndLogResult * _Nullable result) {
640- if (result && result.isValid ) {
641- [self sendEventWithName: @" onValidationResult" body: @" {\" result\" : true, \" message\" : \" In App Purchase Validation completed successfully!\" }" ];
642- } else {
643- [self sendEventWithName: @" onValidationResult" body: @" {\" error\" : \" Purchase validation failed\" }" ];
644- }
645- }];
632+ AFSDKPurchaseDetails* details = [[AFSDKPurchaseDetails alloc ] initWithProductId: productId transactionId: transactionId purchaseType: afPurchaseType];
633+
634+ [[AppsFlyerLib shared ] validateAndLogInAppPurchase: details purchaseAdditionalDetails: additionalParameters completion: ^(NSDictionary * _Nullable response, NSError * _Nullable error) {
635+ if (error == nil ) {
636+ BOOL valid = [response[@" result" ] boolValue ];
637+ if (valid) {
638+ [self sendEventWithName: afOnValidationResult body: @" {\" result\" : true, \" message\" : \" In App Purchase Validation completed successfully!\" }" ];
639+ } else {
640+ NSString *msg = response[@" message" ] ?: @" Purchase validation failed" ;
641+ [self sendEventWithName: afOnValidationResult body: @" {\" result\" : false, \" message\" : \" Purchase validation failed\" }" ];
642+ }
643+ } else {
644+ [self sendEventWithName: afOnValidationResult body: [NSString stringWithFormat: @" {\" error\" : \" %@ \" }" , error.localizedDescription]];
645+ }
646+ }];
646647}
647648
648649RCT_EXPORT_METHOD (sendPushNotificationData: (NSDictionary *)pushPayload errorCallBack:(RCTResponseErrorBlock)errorCallBack) {
0 commit comments