'Background Task 9 ("SKReceiptRefreshRequest"), was created over 30 seconds ago?

i am using SwiftyStoreKit SDK for in app purchase into my application

for some reason , the restore is not working and i am getting this message in xCode console

Log :

[BackgroundTask] Background Task 1 ("SKReceiptRefreshRequest"), was created over 30 seconds
     ago. In applications running in the background, this creates a risk of termination. Remember to
     call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

My restore purchase code :

SwiftyStoreKit.restorePurchases(atomically: true) { results in
    if results.restoreFailedPurchases.count > 0 {
        print("Restore Failed: \(results.restoreFailedPurchases)")
    }
    else if results.restoredPurchases.count > 0 {


SwiftyStoreKit.fetchReceipt(forceRefresh: true) { result in
    switch result {
    case .success(let receiptData):
        let encryptedReceipt = receiptData.base64EncodedString(options: [])
        print("Fetch receipt success:\n\(encryptedReceipt)")
    case .error(let error):
        print("Fetch receipt failed: \(error)")
    }
}

        print("Restore Success: \(results.restoredPurchases)")
    }
    else {
        print("Nothing to Restore")
    }
}

and its keep loading forever without any progress , any idea why ?



Solution 1:[1]

(in Objective C) I can't speak to why SwiftyStoreKit is not working but the error message is the same as a bug for an SKReceiptRefreshRequest in the method [request start];. When the request is returned in requestDidFinish: the request is not properly dealloc'd and needs a [request cancel];

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter B. Kramer