The subscription item redeemed from the Appstore cannot be detected within the app(storekit2,promo code)

The minimum support for the project is iOS 15.2, and the subscription function is implemented using StoreKit2. Problem: The redemption was successful within the Appstore, but the redemption item cannot be detected through code within the app.(The subscription function has been implemented and tested)

Here is my code, I am not sure if it is due to storeKit2 (as seen elsewhere) or if there is a problem with the testing method. If there is a correct testing method for the promoCode redemption scenario, please let me know.

for await verificationResult in Transaction.currentEntitlements {
            switch verificationResult {
            case .verified(let transaction):
                if transaction.revocationDate != nil {
                    print("unsubscribe:\(transaction)")
                    break
                }
                if transaction.offerType == .code,let code = transaction.offerID {
                    print("Have promoCode")
                    print("promoCode: \(code)")
                    let dateF = DateFormatter()
                    dateF.dateFormat = "yyyy.MM.dd HH.mm.ss"
                    if let expireDate = transaction.expirationDate {
                        print("endTime:\(dateF.string(from: expireDate))")
                    }
                }
                //.consumable,.nonConsumable,.autoRenewable,.nonRenewable
                if transaction.productType == .autoRenewable {
                    print("Have subscription:\(transaction)")
                    let dateF = DateFormatter()
                    dateF.dateFormat = "yyyy.MM.dd HH.mm.ss"
                    if let expireDate = transaction.expirationDate {
                        print("endTime:\(dateF.string(from: expireDate))")
                    }
                }else{
                    print("\(transaction)")
                }
            case .unverified(let unverifiedTransaction, let verificationError):
                print("checkProduct:error")
            }
        }

if transaction.offerType == .code always false

The subscription item redeemed from the Appstore cannot be detected within the app(storekit2,promo code)
 
 
Q