mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
Fixes [CF-684] and #1594. `SystemInfo.appleSubscriptionsURL` was a short URL that didn't pass the `SystemInfo.isAppleSubscription(managementURL:)` test. This is fixed and covered by a test now. ### Other changes: - Made `SystemInfo.isAppleSubscription(managementURL:)` and `SystemInfo.appleSubscriptionsURL` static since they don't need any properties in `SystemInfo`. - Forced-unwrapped `SystemInfo.appleSubscriptionsURL` to remove unnecessary error handling. This is safe because the URL is provided statically at compile time. Per the docs "This initializer returns nil if the string doesn’t represent a valid URL. For example, an empty string or one containing characters that are illegal in a URL produces nil.". This is known at compile time, and covered by tests, so it could never return `nil`. - Combined redundant tests in `ManageSubscriptionsHelper`. They were all doing exactly the same for both platforms. [CF-684]: https://revenuecats.atlassian.net/browse/CF-684?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
53 lines
1.8 KiB
Swift
53 lines
1.8 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// ManageSubscriptionsStrings.swift
|
|
//
|
|
// Created by Andrés Boedo on 13/12/21.
|
|
|
|
import Foundation
|
|
|
|
// swiftlint:disable identifier_name
|
|
|
|
extension ManageSubscriptionsHelper {
|
|
|
|
enum Strings {
|
|
|
|
case error_from_appstore_show_manage_subscription(error: Error)
|
|
case failed_to_get_management_url_error_unknown(error: Error)
|
|
case failed_to_get_window_scene
|
|
case management_url_nil_opening_default
|
|
case show_manage_subscriptions_called_in_unsupported_platform
|
|
case susbscription_management_sheet_dismissed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extension ManageSubscriptionsHelper.Strings: CustomStringConvertible {
|
|
|
|
var description: String {
|
|
switch self {
|
|
case .error_from_appstore_show_manage_subscription(let error):
|
|
return "Error when trying to show manage subscription: \(error.localizedDescription)"
|
|
case .failed_to_get_management_url_error_unknown(let error):
|
|
return "Failed to get managementURL from CustomerInfo. Details: \(error.localizedDescription)"
|
|
case .failed_to_get_window_scene:
|
|
return "Failed to get UIWindowScene"
|
|
case .management_url_nil_opening_default:
|
|
return "managementURL is nil, opening Apple's subscription management page"
|
|
case .susbscription_management_sheet_dismissed:
|
|
return "Subscription management sheet dismissed."
|
|
case .show_manage_subscriptions_called_in_unsupported_platform:
|
|
return "tried to call AppStore.showManageSubscriptions in a platform that doesn't support it!"
|
|
}
|
|
}
|
|
|
|
}
|