Skip to main content
Question

Presenting Paywall on every n launches

  • September 4, 2024
  • 2 replies
  • 54 views

Forum|alt.badge.img+1

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?.entitlements["pro"]?.isActive == true
print("hasPro: \(self.hasPro))")
}
}
}
}

 

This post has been closed for comments

2 replies

wes_clark
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • September 6, 2024

Hi! Happy to take a look at this! Can you share the code snippet from your presentPaywall method so I can take a look at how you are calling our methods?


Forum|alt.badge.img+1

Thanks for reaching out @wes_clark. I'm good to go, I was able to get past this. Much appreciate the offer to help!