Hi Guys,
I am developing IOS purchases on a physical device.
Everything was working fine until I upgrade to IOS 14 version.
Device: Physical iPhone 6
IOS: 14
The problem:
I tried removing the call from the restore purchases and it works fine without this one.
It is the library react-native-iap that I am using
I am developing IOS purchases on a physical device.
Everything was working fine until I upgrade to IOS 14 version.
Device: Physical iPhone 6
IOS: 14
The problem:
Before making a purchase I send to verify the restore purchases with my backend
I check that the user does not have active subscriptions
If the user does not have active subscriptions, I will send him to buy a subscription
The purchase popup never appears
I tried removing the call from the restore purchases and it works fine without this one.
Code Block RCT_EXPORT_METHOD(getAvailableItems:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { [self addPromiseForKey:@"availableItems" resolve:resolve reject:reject]; [[SKPaymentQueue defaultQueue] restoreCompletedTransactions]; }
Code Block -(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue { //////// RESTORE NSLog(@"\n\n\n paymentQueueRestoreCompletedTransactionsFinished \n\n."); NSMutableArray* items = [NSMutableArray arrayWithCapacity:queue.transactions.count]; for(SKPaymentTransaction *transaction in queue.transactions) { if(transaction.transactionState == SKPaymentTransactionStateRestored || transaction.transactionState == SKPaymentTransactionStatePurchased) { [self getPurchaseData:transaction withBlock:^(NSDictionary *restored) { [items addObject:restored]; [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; }]; } } [self resolvePromisesForKey:@"availableItems" value:items]; }
Code Block -(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error { dispatch_sync(myQueue, ^{ [self rejectPromisesForKey:@"availableItems" code:[self standardErrorCode:(int)error.code] message:error.localizedDescription error:error]; }); NSLog(@"\n\n\n restoreCompletedTransactionsFailedWithError \n\n."); }
Code Block RCT_EXPORT_METHOD(buyProduct:(NSString*)sku andDangerouslyFinishTransactionAutomatically:(BOOL)finishAutomatically resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) { pendingTransactionWithAutoFinish = finishAutomatically; SKProduct *product; @synchronized (validProducts) { for (SKProduct *p in validProducts) { if([sku isEqualToString:p.productIdentifier]) { product = p; break; } } } if (product) { [self addPromiseForKey:product.productIdentifier resolve:resolve reject:reject]; SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product]; [[SKPaymentQueue defaultQueue] addPayment:payment]; } else { if (hasListeners) { NSDictionary *err = [NSDictionary dictionaryWithObjectsAndKeys: @"Invalid product ID.", @"debugMessage", @"E_DEVELOPER_ERROR", @"code", @"Invalid product ID.", @"message", sku, @"productId", nil ]; [self sendEventWithName:@"purchase-error" body:err]; } reject(@"E_DEVELOPER_ERROR", @"Invalid product ID.", nil); } }
It is the library react-native-iap that I am using
Same question
If the user has purchased the product but it expires,
At this point, click restore to buy,
Click buy, he will not pop up the Apple Pay page