Open mvn-hangtran-dn opened 3 months ago
Do you have any way to reproduce the error?
@britannio You can call requestReview(in:) when the scene hasn't attached. So the active scene is nil and review dialog can not show. By the way, why do you need to use an active scene? I tried to use an unattached scene and the review dialog can show with it. I'm not sure about mechanism of scene.
What do you think about this suggestion?
try catch
to make sure that we don’t have any crash with other scene states.
func requestReview() {
do {
if #available(iOS 14, *) {
print(“iOS 14+“)
let scenes = UIApplication.shared.connectedScenes
// Find and get the first foregroundActive scene
if let activeScene = scenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
SKStoreReviewController.requestReview(in: activeScene)
} else {
// Use the first scene if there is no foregroundActive scene
// this seemed to fix the issue in our app
if let firstScene = scenes.first as? UIWindowScene {
print(“Scene state: \(firstScene.activationState)“)
SKStoreReviewController.requestReview(in: firstScene)
} else {
print(“No scene”)
}
}
} else if #available(iOS 10.3, *) {
print(“iOS 10.3+“)
SKStoreReviewController.requestReview()
} else {
print(“In-App Review unavailable”)
}
} catch {
print(“An error occured when requesting review dialog”)
}
}
https://github.com/britannio/in_app_review/commit/1faabe24a94760d4dedc4268e6cb995185ccfdf1
Presumably this change is sufficient?
Follow this official document, review dialog is always displayed. But I tested found that sometimes it doesn't display without error. Seem like foregroundActive state of scene can not be founded. iOS version: 16.3
flutter doctor -v