     
     func requestDidFinish(with error: Error?)
     {
-        UIApplication.shared.endBackgroundTask(self.backgroundTaskID!)
-        
         DispatchQueue.main.async { [weak self] in
             self?.completion?(error)
         }


public typealias IAPRefreshRequestResult = ((Error?) -> ())

fileprivate class RefreshSession : NSObject, SKRequestDelegate
{
    private let receiptRefreshRequest = SKReceiptRefreshRequest()
    private var completion: IAPRefreshRequestResult?
    
    private var backgroundTaskID: UIBackgroundTaskIdentifier?
    
    override init()
    {
        super.init()
        
        #if targetEnvironment(macCatalyst) || os(iOS) || os(tvOS)
        
        #endif
        
        self.backgroundTaskID = UIApplication.shared.beginBackgroundTask (withName: "IARRefreshTask")
        {
            UIApplication.shared.endBackgroundTask(self.backgroundTaskID!)
            self.backgroundTaskID = UIBackgroundTaskIdentifier.invalid
        }
        
        receiptRefreshRequest.delegate = self
    }
    

import Foundation
import StoreKit

@available(watchOSApplicationExtension 6.2, *)
fileprivate var refreshSession: RefreshSession?

public extension InAppReceipt
