Skip to content

Commit

Permalink
Merge pull request #1274 from HedvigInsurance/feature/GEN-1877-ask-fo…
Browse files Browse the repository at this point in the history
…r-review

GEN-1877: Added ask for review after successful self service
  • Loading branch information
sladan-hedvig authored Mar 8, 2024
2 parents d5ac051 + 47468b7 commit a23db2e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Projects/Chat/Sources/Views/ChatScreenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ChatScreenViewModel: ObservableObject {
let fileUploadManager = FileUploadManager()
fileUploadManager.resetuploadFilesPath()
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
AskForRating().ask()
AskForRating().askAccordingToTheNumberOfSessions()
}
log.addUserAction(type: .click, name: "Chat open", error: nil, attributes: nil)
let store: ChatStore = globalPresentableStoreContainer.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public final class EditCoInsuredStore: LoadingStateStore<
try await self.editCoInsuredService.sendMidtermChangeIntentCommit(commitId: commitId)
self.removeLoading(for: .postCoInsured)
send(.fetchContracts)
AskForRating().askForReview()
} catch {
self.setError(L10n.General.errorBody, for: .postCoInsured)
}
Expand Down
1 change: 1 addition & 0 deletions Projects/MoveFlow/Sources/Store/MoveFlowStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public final class MoveFlowStore: LoadingStateStore<MoveFlowState, MoveFlowActio
let intentId = self.state.movingFlowModel?.id ?? ""
try await self.moveFlowService.confirmMoveIntent(intentId: intentId)
self.removeLoading(for: .confirmMoveIntent)
AskForRating().askForReview()
} catch {
self.setError(error.localizedDescription, for: .confirmMoveIntent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public final class TravelInsuranceStore: LoadingStateStore<
)
do {
let url = try await self.travelInsuranceClient.submitForm(dto: dto)
AskForRating().askForReview()
send(.setDownloadUrl(urL: url))
} catch _ {
self.setError(L10n.General.errorBody, for: .postTravelInsurance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@ public struct AskForRating {
UserDefaults.standard.set(numberOfSessions, forKey: userDefaultsKey)
}

func ask() {
public func askAccordingToTheNumberOfSessions() {
guard !UserDefaults.standard.bool(forKey: userDefaultsCompletedKey) else { return }

let numberOfSessions = UserDefaults.standard.value(forKey: "AskForRating") as? Int ?? 0

if numberOfSessions >= 3 {
UserDefaults.standard.set(true, forKey: userDefaultsCompletedKey)
askForReview()
}
}

public func askForReview() {
guard !UserDefaults.standard.bool(forKey: userDefaultsCompletedKey) else { return }
UserDefaults.standard.set(true, forKey: userDefaultsCompletedKey)
DispatchQueue.main.async {
if let scene = UIApplication.shared.currentScene {
SKStoreReviewController.requestReview(in: scene)
}
}
}

}

extension UIApplication {
Expand Down

0 comments on commit a23db2e

Please sign in to comment.