mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 19:11:10 +00:00
Fix review prompt on iOS
This commit is contained in:
1 parent
951b783902
commit
f9a7201282
2 files changed
+19
-1
No files matched your search
@@ -7,6 +7,7 @@
|
||||
|
||||
import SwiftUI
|
||||
import LUI
|
||||
import StoreKit
|
||||
|
||||
struct ContentView: View {
|
||||
|
||||
@@ -37,6 +38,7 @@ struct DeviceListView: View {
|
||||
#endif
|
||||
|
||||
@Environment(\.scenePhase) var scenePhase
|
||||
@AppStorage("requestedReview") private var requestedReview = false
|
||||
@ObservedObject var nearbyConnectionManager = NearbyConnectionManager.shared
|
||||
|
||||
var body: some View {
|
||||
@@ -144,10 +146,23 @@ struct DeviceListView: View {
|
||||
if newValue == .active {
|
||||
|
||||
log("App became active")
|
||||
NearbyConnectionManager.shared.startDeviceDiscovery()
|
||||
#if !EXTENSION
|
||||
NearbyConnectionManager.shared.becomeVisible()
|
||||
|
||||
if incomingTransmissionCount() > 0 && !requestedReview {
|
||||
runAfter(seconds: 0.3) {
|
||||
if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
|
||||
|
||||
SKStoreReviewController.requestReview(in: scene)
|
||||
requestedReview = true
|
||||
}
|
||||
else {
|
||||
log("Error Requesting Review!")
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
NearbyConnectionManager.shared.startDeviceDiscovery()
|
||||
}
|
||||
|
||||
if newValue == .background {
|
||||
|
||||
@@ -156,11 +156,14 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
|
||||
}
|
||||
|
||||
let currentCount = incomingTransmissionCount()
|
||||
|
||||
#if os(macOS)
|
||||
if currentCount == 0 {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
SKStoreReviewController.requestReview()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
UserDefaults.standard.set(currentCount + 1, forKey: UserDefaultsKeys.transmissionCount.rawValue)
|
||||
log("[ReceiveModel] Successful transmission. Current count: \(currentCount)")
|
||||
|
||||
Reference in new issue
Block a user