Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Beeblex developer here. The code inside -validateWithCompletionBlock: execute asynchronously (in the background, it needs to talk to our servers, so there's no point blocking your app completely while we wait for the Internet to do its thing).</p> <p>Therefore, you need to rethink your approach to validating your receipts. Right now you, general workflow is:</p> <ol> <li>Complete purchase</li> <li>Call Beeblex</li> <li>Wait for response</li> <li>Check boolean value</li> </ol> <p>But #3 returns right away, so this will never work. You should consider doing something like this:</p> <ol> <li>Complete purchase</li> <li>Show a “Please wait…” view, or something similar that advises the user that you're unlocking whatever they've purchased.</li> <li>Call Beeblex</li> <li>Inside the block, determine whether the validation succeeded or not, and <em>then</em> act to unlock the content from there.</li> <li>Sit idle until called by the block</li> </ol> <p>Here's a quick-and-dirty example. I didn't compile it, so it probably has a few bugs, but it should give you the idea behind the intended usage pattern.</p> <pre><code>- (void) showWaitView { // Display a wait view } - (void) hideWaitView { // Hide the wait view } - (void) completeValidationWithValidateReceiptData:(NSDictionary *) receipt isRecoverableError(BOOL) isRecoverableError { [self hideWaitView]; if (receipt) { // Unlock the content, tell the user } else { if (isRecoverableError) { // Probably a network error of some kind. Tell user they need to be connected, // and ask them to do it again. } else { // Keep the content locked, tell the user something went wrong } } } - (void) validateReceipt:(SKPaymentTransaction *) transaction { if (![BBXIAPTransaction canValidateTransactions]) { [self completeValidationWithValidateReceiptData:Nil isRecoverableError:YES]; return; } BBXIAPTransaction *bbxTransaction = [[BBXIAPTransaction alloc] initWithTransaction:transaction]; bbxTransaction.useSandbox = YES; [bbxTransaction validateWithCompletionBlock:^(NSError *error) { if (bbxTransaction.transactionVerified) { if (bbxTransaction.transactionIsDuplicate) { // The transaction is valid, but duplicate - it has already been sent to Beeblex in the past. [FlurryAnalytics logEvent:@"Transaction duplicate!"]; [self completeValidationWithValidateReceiptData:Nil isRecoverableError:NO]; } else { // The transaction has been successfully validated and is unique [FlurryAnalytics logEvent:@"Transaction verified"]; [self completeValidationWithValidateReceiptData:bbxTransaction.validatedTransactionData isRecoverableError:NO]; } } else { // Check whether this is a validation error, or if something went wrong with Beeblex if (bbxTransaction.hasConfigurationError || bbxTransaction.hasServerError || bbxTransaction.hasClientError) { // The error was not caused by a problem with the data, but is most likely due to some transient networking issues [FlurryAnalytics logEvent:@"Transaction network error"]; [self completeValidationWithValidateReceiptData:Nil isRecoverableError:YES]; } else { // The transaction supplied to the validation service was not valid according to Apple [FlurryAnalytics logEvent:@"Transaction invalid!!"]; [self completeValidationWithValidateReceiptData:Nil isRecoverableError:NO]; } } }]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload