79318416

Date: 2024-12-30 19:17:55
Score: 0.5
Natty:
Report link

Thanks @Paulw11, now I understand. Execution just continues after the call to the Swift code, you need to just let the completion block do it's thing, and handle things from there.

The Objective-C code now is:

- (void) ReceiptValidatedWith:(int)validation_code
{        
    if (validation_code != 1) {
        ALog(@"AppStore receipt invalid, exiting.");
        [NSApp terminate:self];
    }
    else {
        ALog(@"AppStore receipt VALID, continuing.");
    }
}

- (void) validateReceipt
// Validating receipt now only possible via Swift, call method AppTransaction.shared in swift module.
// As that all is async code we need to jump through some hoops to get at the value of the validity code.
{
    ALog(@"validating receipt...");
    
    [self.receiptValidation getValidityOfAppStoreReceiptWithCompletionHandler:^(NSInteger validation_code, NSError *error) {
        [self ReceiptValidatedWith:validation_code];  // called on completion of the Swift code
    }];
}

Just for the heck of it the code to interface to Swift:

.h

// AppStore receipt validation module (Swift)
@property (nonatomic,strong) ReceiptValidation *receiptValidation;  // swift

.m

@synthesize receiptValidation;  // swift module

// AppStore receipt validation with swift module
self.receiptValidation = [[ReceiptValidation alloc] init];
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Paulw11
  • Self-answer (0.5):
Posted by: RickJansen