Skip to content

Commit

Permalink
Customer Center deeplinks should always be opened externally (#4533)
Browse files Browse the repository at this point in the history
* check if it's a deeplink

* match http or https

* add log
  • Loading branch information
vegaro authored Dec 4, 2024
1 parent 69baa32 commit 3f4c4eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
13 changes: 13 additions & 0 deletions RevenueCatUI/CustomerCenter/URLUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ enum URLUtilities {

}

extension URL {

var isDeeplink: Bool {
switch scheme?.lowercased() {
case "http", "https":
return false
default:
return true
}
}

}

private extension URLUtilities {

static var isAppExtension: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,14 @@ private extension ManageSubscriptionsViewModel {
return
}
switch openMethod {
case .external:
case .external,
_ where url.isDeeplink:
URLUtilities.openURLIfNotAppExtension(url)
case .inApp:
self.inAppBrowserURL = .init(url: url)
@unknown default:
Logger.warning(Strings.could_not_determine_type_of_custom_url)
URLUtilities.openURLIfNotAppExtension(url)
}
default:
break
Expand Down
4 changes: 4 additions & 0 deletions RevenueCatUI/Data/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ enum Strings {
case could_not_offer_for_active_subscriptions(String, String)
case error_fetching_promotional_offer(Error)
case promo_offer_not_loaded
case could_not_determine_type_of_custom_url

}

Expand Down Expand Up @@ -207,6 +208,9 @@ extension Strings: CustomStringConvertible {
case .could_not_offer_for_active_subscriptions(let discount, let subscription):
return "Could not find offer with id \(discount) for active subscription \(subscription)"

case .could_not_determine_type_of_custom_url:
return "Could not determine the type of custom URL, the URL will be opened externally."

}
}

Expand Down

0 comments on commit 3f4c4eb

Please sign in to comment.