Skip to content

Commit

Permalink
Add getAccessToken handler
Browse files Browse the repository at this point in the history
  • Loading branch information
afterxleep committed May 2, 2024
1 parent e55ed69 commit 081b395
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature {
static let subscriptionsUnknownPriceClicked = "subscriptionsUnknownPriceClicked"
static let subscriptionsAddEmailSuccess = "subscriptionsAddEmailSuccess"
static let subscriptionsWelcomeFaqClicked = "subscriptionsWelcomeFaqClicked"
static let getAccessToken = "getAccessToken"
}

// swiftlint:disable:next cyclomatic_complexity
Expand All @@ -124,6 +125,7 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature {
case Handlers.subscriptionsUnknownPriceClicked: return subscriptionsUnknownPriceClicked
case Handlers.subscriptionsAddEmailSuccess: return subscriptionsAddEmailSuccess
case Handlers.subscriptionsWelcomeFaqClicked: return subscriptionsWelcomeFaqClicked
case Handlers.getAccessToken: return getAccessToken
default:
return nil
}
Expand Down Expand Up @@ -448,6 +450,14 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature {
return nil
}

func getAccessToken(params: Any, original: WKScriptMessage) async throws -> Encodable? {
if let accessToken = AccountManager(subscriptionAppGroup: Bundle.main.appGroup(bundle: .subs)).accessToken {
return ["token": accessToken]
} else {
return [String: String]()
}
}

// MARK: Push actions

enum SubscribeActionName: String {
Expand Down

0 comments on commit 081b395

Please sign in to comment.