takecian/SwiftRater

SwiftUI Support

JulesMoorhouse opened this issue · 2 comments

Hey,

I've used SwiftRater in other older apps in the past, Objective C apps, I've found it works really well.

I'd really like to use this with SwiftUI now.

Jules.

@JulesMoorhouse you can easily do it in SwiftUI with something like this

@main
struct SwiftRateDemoApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
SwiftRater.daysUntilPrompt = 7
        SwiftRater.usesUntilPrompt = 10
        SwiftRater.significantUsesUntilPrompt = 3
        SwiftRater.daysBeforeReminding = 1
        SwiftRater.showLaterButton = true
        SwiftRater.debugMode = true
        SwiftRater.appLaunched()
        return true
    }
}

More info about UIApplicationDelegateAdaptor here

Thanks markgravity for the follow up.
I've added this in README.
3cf8ff5