I want to present the Paywall, if needed, on every 4th launch of the app. I can track the launch count, but can’t seem to figure out how to couple this with .presentPaywallIfNeeded in the ContentView.
// Show paywall every 4th launch
if launchCount % 4 == 0 {
// Present RevenueCat Paywall
presentPaywall()
}
import Foundation
import RevenueCat
class SubscriptionManager: ObservableObject {
@Published var hasPro: Bool = false
init() {
checkSubscriptionStatus()
}
func checkSubscriptionStatus() {
Purchases.shared.getCustomerInfo { (customerInfo, error) in
if let error = error {
print("Error fetching customer info: \(error.localizedDescription)")
return
}
print("checkSubscriptionStatus")
DispatchQueue.main.async {
self.hasPro = customerInfo?.entitlementsn"pro"]?.isActive == true
print("hasPro: \(self.hasPro))")
}
}
}
}