mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
BuyInAppStore button
This commit is contained in:
parent
6e70a5b77c
commit
745078e2d4
@ -13,7 +13,7 @@ import TelegramUIPreferences
|
|||||||
|
|
||||||
|
|
||||||
@available(iOS 13.0, *)
|
@available(iOS 13.0, *)
|
||||||
public func sgPayWallController(statusSignal: Signal<Int64, NoError>, replacementController: ViewController, presentationData: PresentationData? = nil, SGIAPManager: SGIAPManager, openUrl: @escaping (String) -> Void, paymentsEnabled: Bool) -> ViewController {
|
public func sgPayWallController(statusSignal: Signal<Int64, NoError>, replacementController: ViewController, presentationData: PresentationData? = nil, SGIAPManager: SGIAPManager, openUrl: @escaping (String) -> Void, paymentsEnabled: Bool, canBuyInBeta: Bool, openAppStorePage: @escaping () -> Void) -> ViewController {
|
||||||
// let theme = presentationData?.theme ?? (UITraitCollection.current.userInterfaceStyle == .dark ? defaultDarkColorPresentationTheme : defaultPresentationTheme)
|
// let theme = presentationData?.theme ?? (UITraitCollection.current.userInterfaceStyle == .dark ? defaultDarkColorPresentationTheme : defaultPresentationTheme)
|
||||||
let theme = defaultDarkColorPresentationTheme
|
let theme = defaultDarkColorPresentationTheme
|
||||||
let strings = presentationData?.strings ?? defaultPresentationStrings
|
let strings = presentationData?.strings ?? defaultPresentationStrings
|
||||||
@ -30,7 +30,7 @@ public func sgPayWallController(statusSignal: Signal<Int64, NoError>, replacemen
|
|||||||
let swiftUIView = SGSwiftUIView<SGPayWallView>(
|
let swiftUIView = SGSwiftUIView<SGPayWallView>(
|
||||||
legacyController: legacyController,
|
legacyController: legacyController,
|
||||||
content: {
|
content: {
|
||||||
SGPayWallView(wrapperController: legacyController, replacementController: replacementController, SGIAP: SGIAPManager, statusSignal: statusSignal, openUrl: openUrl, paymentsEnabled: paymentsEnabled)
|
SGPayWallView(wrapperController: legacyController, replacementController: replacementController, SGIAP: SGIAPManager, statusSignal: statusSignal, openUrl: openUrl, openAppStorePage: openAppStorePage, paymentsEnabled: paymentsEnabled, canBuyInBeta: canBuyInBeta)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
let controller = UIHostingController(rootView: swiftUIView, ignoreSafeArea: true)
|
let controller = UIHostingController(rootView: swiftUIView, ignoreSafeArea: true)
|
||||||
@ -106,7 +106,9 @@ struct SGPayWallView: View {
|
|||||||
let SGIAP: SGIAPManager
|
let SGIAP: SGIAPManager
|
||||||
let statusSignal: Signal<Int64, NoError>
|
let statusSignal: Signal<Int64, NoError>
|
||||||
let openUrl: (String) -> Void
|
let openUrl: (String) -> Void
|
||||||
|
let openAppStorePage: () -> Void
|
||||||
let paymentsEnabled: Bool
|
let paymentsEnabled: Bool
|
||||||
|
let canBuyInBeta: Bool
|
||||||
|
|
||||||
private enum PayWallState: Equatable {
|
private enum PayWallState: Equatable {
|
||||||
case ready // ready to buy
|
case ready // ready to buy
|
||||||
@ -405,6 +407,8 @@ struct SGPayWallView: View {
|
|||||||
} else if let product = product {
|
} else if let product = product {
|
||||||
if !SGIAP.canMakePayments || paymentsEnabled == false {
|
if !SGIAP.canMakePayments || paymentsEnabled == false {
|
||||||
return "PayWall.Button.PaymentsUnavailable".i18n(lang)
|
return "PayWall.Button.PaymentsUnavailable".i18n(lang)
|
||||||
|
} else if Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt" && !canBuyInBeta {
|
||||||
|
return "PayWall.Button.BuyInAppStore".i18n(lang)
|
||||||
} else {
|
} else {
|
||||||
return "PayWall.Button.Subscribe".i18n(lang, args: product.price)
|
return "PayWall.Button.Subscribe".i18n(lang, args: product.price)
|
||||||
}
|
}
|
||||||
@ -429,12 +433,16 @@ struct SGPayWallView: View {
|
|||||||
private func handlePurchase() {
|
private func handlePurchase() {
|
||||||
if currentStatus > 1 {
|
if currentStatus > 1 {
|
||||||
wrapperController?.replace(with: replacementController)
|
wrapperController?.replace(with: replacementController)
|
||||||
|
} else {
|
||||||
|
if Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt" && !canBuyInBeta {
|
||||||
|
openAppStorePage()
|
||||||
} else {
|
} else {
|
||||||
guard let product = product else { return }
|
guard let product = product else { return }
|
||||||
state = .purchasing
|
state = .purchasing
|
||||||
SGIAP.buyProduct(product.skProduct)
|
SGIAP.buyProduct(product.skProduct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func handleRestorePurchases() {
|
private func handleRestorePurchases() {
|
||||||
state = .restoring
|
state = .restoring
|
||||||
|
@ -227,6 +227,7 @@
|
|||||||
"PayWall.Button.Restoring" = "Restoring Purchases...";
|
"PayWall.Button.Restoring" = "Restoring Purchases...";
|
||||||
"PayWall.Button.Validating" = "Validating Purchase...";
|
"PayWall.Button.Validating" = "Validating Purchase...";
|
||||||
"PayWall.Button.PaymentsUnavailable" = "Payments unavailable";
|
"PayWall.Button.PaymentsUnavailable" = "Payments unavailable";
|
||||||
|
"PayWall.Button.BuyInAppStore" = "Subscribe in App Store version";
|
||||||
"PayWall.Button.Subscribe" = "Subscribe for %@ / month";
|
"PayWall.Button.Subscribe" = "Subscribe for %@ / month";
|
||||||
"PayWall.Button.ContactingAppStore" = "Contacting App Store...";
|
"PayWall.Button.ContactingAppStore" = "Contacting App Store...";
|
||||||
|
|
||||||
|
@ -194,10 +194,10 @@
|
|||||||
"PayWall.Text" = "Заряжен Pro функциями";
|
"PayWall.Text" = "Заряжен Pro функциями";
|
||||||
|
|
||||||
"PayWall.SessionBackup.Title" = "Бэкап Аккаунтов";
|
"PayWall.SessionBackup.Title" = "Бэкап Аккаунтов";
|
||||||
"PayWall.SessionBackup.Notice" = "Вход в аккаунты без кодов, даже после переустановки. Безопасное хранение в Keychain на устройстве.";
|
"PayWall.SessionBackup.Notice" = "Вход в аккаунты без кода, даже после переустановки. Безопасное хранение в Keychain на устройстве.";
|
||||||
|
|
||||||
"PayWall.MessageFilter.Title" = "Фильтр сообщений";
|
"PayWall.MessageFilter.Title" = "Фильтр сообщений";
|
||||||
"PayWall.MessageFilter.Notice" = "Уменьшает видимость надоедливых сообщений со СПАМом или рекламой";
|
"PayWall.MessageFilter.Notice" = "Уменьшает видимость надоедливых сообщений со СПАМом или рекламой.";
|
||||||
|
|
||||||
"PayWall.Notifications.Title" = "Отключение @тэгов и ответов";
|
"PayWall.Notifications.Title" = "Отключение @тэгов и ответов";
|
||||||
"PayWall.Notifications.Notice" = "Скрывает или приглушает неважные уведомления.";
|
"PayWall.Notifications.Notice" = "Скрывает или приглушает неважные уведомления.";
|
||||||
@ -227,6 +227,7 @@
|
|||||||
"PayWall.Button.Restoring" = "Восстановление покупок...";
|
"PayWall.Button.Restoring" = "Восстановление покупок...";
|
||||||
"PayWall.Button.Validating" = "Проверка покупки...";
|
"PayWall.Button.Validating" = "Проверка покупки...";
|
||||||
"PayWall.Button.PaymentsUnavailable" = "Платежи недоступны";
|
"PayWall.Button.PaymentsUnavailable" = "Платежи недоступны";
|
||||||
|
"PayWall.Button.BuyInAppStore" = "Подписаться в App Store версии";
|
||||||
"PayWall.Button.Subscribe" = "Подписаться за %@ / месяц";
|
"PayWall.Button.Subscribe" = "Подписаться за %@ / месяц";
|
||||||
"PayWall.Button.ContactingAppStore" = "Подключение к App Store...";
|
"PayWall.Button.ContactingAppStore" = "Подключение к App Store...";
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ public struct SGWebSettings: Codable, Equatable {
|
|||||||
public let user: SGUserSettings
|
public let user: SGUserSettings
|
||||||
|
|
||||||
public static var defaultValue: SGWebSettings {
|
public static var defaultValue: SGWebSettings {
|
||||||
return SGWebSettings(global: SGGlobalSettings(ytPip: true, qrLogin: true, storiesAvailable: false, canViewMessages: true, canEditSettings: false, canShowTelescope: false, announcementsData: nil, regdateFormat: "full", botMonkeys: [], forceReasons: [], unforceReasons: [], paymentsEnabled: true, duckyAppIconAvailable: true, canGrant: false), user: SGUserSettings(contentReasons: [], canSendTelescope: false))
|
return SGWebSettings(global: SGGlobalSettings(ytPip: true, qrLogin: true, storiesAvailable: false, canViewMessages: true, canEditSettings: false, canShowTelescope: false, announcementsData: nil, regdateFormat: "full", botMonkeys: [], forceReasons: [], unforceReasons: [], paymentsEnabled: true, duckyAppIconAvailable: true, canGrant: false), user: SGUserSettings(contentReasons: [], canSendTelescope: false, canBuyInBeta: true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ public struct SGBotMonkeys: Codable, Equatable {
|
|||||||
public struct SGUserSettings: Codable, Equatable {
|
public struct SGUserSettings: Codable, Equatable {
|
||||||
public let contentReasons: [String]
|
public let contentReasons: [String]
|
||||||
public let canSendTelescope: Bool
|
public let canSendTelescope: Bool
|
||||||
|
public let canBuyInBeta: Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3624,7 +3624,8 @@ extension SharedAccountContextImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let proController = self.makeSGProController(context: context)
|
let proController = self.makeSGProController(context: context)
|
||||||
let payWallController = sgPayWallController(statusSignal: statusSignal, replacementController: proController, presentationData: self.currentPresentationData.with { $0 }, SGIAPManager: sgIAP, openUrl: self.applicationBindings.openUrl, paymentsEnabled: context.currentAppConfiguration.with { $0 }.sgWebSettings.global.paymentsEnabled)
|
let sgWebSettings = context.currentAppConfiguration.with { $0 }.sgWebSettings
|
||||||
|
let payWallController = sgPayWallController(statusSignal: statusSignal, replacementController: proController, presentationData: self.currentPresentationData.with { $0 }, SGIAPManager: sgIAP, openUrl: self.applicationBindings.openUrl, paymentsEnabled: sgWebSettings.global.paymentsEnabled, canBuyInBeta: sgWebSettings.user.canBuyInBeta, openAppStorePage: self.applicationBindings.openAppStorePage)
|
||||||
return payWallController
|
return payWallController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user