Detect if the app installed from AppStore

Updated
Aug 22, 2022 4:53 AM
Created
Aug 22, 2022 4:02 AM
Tags
SwiftStoreKit.frameworkMemo
Attributes

import StoreKit

public func isInstalledFromAppStore() -> Bool {
  
  #if targetEnvironment(simulator)
    return false
  #else
    
    guard let receiptURL = Bundle.main.appStoreReceiptURL else {
      Log.error("Not found appStoreReceiptURL 😱")
      return true
    }
    
    Log.debug("appStoreReceiptURL : \(receiptURL.debugDescription)")
    return receiptURL.absoluteString.contains("sandboxReceipt") == false
  #endif
}