bizz84 / bizz84/SwiftyStoreKit

InAppReceiptRefreshRequest's refreshReceiptRequest not call requestDidFinish or didFailWithError

Open
#388 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
6.7k
Forks
801
PR merge metrics
No merged PRs in 30d

Description

### Platform

- [x ] iOS
- [ ] macOS
- [ ] tvOS

### In app purchase type

- [x ] Consumable
- [ ] Non-consumable
- [ x] Auto-Renewable Subscription
- [ ] Non-Renewing Subscription

### Environment

- [ x] Sandbox
- [ x] Production

### Version
0.10.7

### Related issues

## Report

### Issue summary
1. when do a purchase. I use SwiftyStoreKit.verifyReceipt to check whether have unfinished purchase.
2.if no unfinished purchase. I use SwiftyStoreKit.purchaseProduct to buy it.
3. It's all ok for the first time. But when I do a purchase twice.SwiftyStoreKit.verifyReceipt's callback does not invoke.
4. I try to debug the reason. I found InAppReceiptRefreshRequest's refreshReceiptRequest not call requestDidFinish or didFailWithError, but self.refreshReceiptRequest.start() invoked.
5. when I run the app again. It still not work. I have to delete the app. Login out the Apple Account. then I can run the code right at one time.
here is the sample code
```
var serviceType = AppleReceiptValidator.VerifyReceiptURLType.production;
#if DEBUG
serviceType = AppleReceiptValidator.VerifyReceiptURLType.sandbox;
#endif
let appleValidator = AppleReceiptValidator.init(service: serviceType);
// 没有执行的话,这个回调是不会执行的
// https://stackoverflow.com/questions/30114489/skreceiptrefreshrequest-not-working-the-second-time-it-is-called-after-a-cancel
SwiftyStoreKit.verifyReceipt(using: appleValidator, password: IN_APP_PURCHASE_PASSWORD, forceRefresh: true) { (result:VerifyReceiptResult) in
switch result {
case .success(let receiptInfo):
print(receiptInfo);
if let status = receiptInfo["status"] as? Int {
if status == 0 {
if let latest_receipt = receiptInfo["latest_receipt"] as? String {

// have receipt do other things

} else {

SwiftyStoreKit.purchaseProduct(productID, quantity: 1, atomically: isAutoRenew) { result in
switch result {
case .success(let purchase):
print(purchase)
case .error(let error):
print(error);
}
}

}
} else {
print(" (CODE:\(status)")
}
} else {
print(" (CODE:NO_STATUS)")
}
case .error(let error):
print(error);
}
};
```

### What did you expect to happen
1. code run well.

### What happened instead
1. code only can run one time.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.