Skip to content

Commit e2cd4a5

Browse files
author
Isaac
committed
Auth payment help
(cherry picked from commit e69f383)
1 parent fde974e commit e2cd4a5

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@
451451
"Login.PhoneGenericEmailSubject" = "Telegram iOS error: %@";
452452
"Login.PhoneGenericEmailBody" = "I'm trying to use my mobile phone number: %1$@\nBut Telegram shows an error. Please help.\n\nError: %2$@\nApp version: %3$@\nOS version: %4$@\nLocale: %5$@\nMNC: %6$@";
453453

454+
"Login.PhonePaidEmailSubject" = "Payment Issue";
455+
"Login.PhonePaidEmailBody" = "Hello Telegram Support,\n\nI’m experiencing an issue with an in-app purchase on iOS.\nMy phone number: %1$@\nApple ID (email used in the App Store): \nApp version: %2$@\nDevice model / iOS version: %3$@\nApp Store country/region: %4$@\nDate & time of attempt (with timezone): %5$@\nExact error message: \n\n#payment_failed";
454456

455457
"Login.PhoneTitle" = "Your Phone";
456458
"Login.PhonePlaceholder" = "Your phone number";

submodules/AuthorizationUI/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ swift_library(
4545
"//submodules/ContextUI:ContextUI",
4646
"//submodules/InAppPurchaseManager",
4747
"//submodules/TelegramUI/Components/Premium/PremiumCoinComponent",
48+
"//submodules/TelegramUI/Components/PlainButtonComponent",
4849
],
4950
visibility = [
5051
"//visibility:public",

submodules/AuthorizationUI/Sources/AuthorizationSequencePaymentScreen.swift

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import AlertUI
2626
import MessageUI
2727
import CoreTelephony
2828
import PhoneNumberFormat
29+
import PlainButtonComponent
30+
import StoreKit
2931

3032
final class AuthorizationSequencePaymentScreenComponent: Component {
3133
typealias EnvironmentType = ViewControllerComponentContainer.Environment
@@ -75,6 +77,7 @@ final class AuthorizationSequencePaymentScreenComponent: Component {
7577
private let list = ComponentView<Empty>()
7678
private let check = ComponentView<Empty>()
7779
private let button = ComponentView<Empty>()
80+
private let helpButton = ComponentView<Empty>()
7881

7982
private var isUpdating: Bool = false
8083

@@ -223,6 +226,51 @@ final class AuthorizationSequencePaymentScreenComponent: Component {
223226
}
224227

225228
let sideInset: CGFloat = 16.0 + environment.safeInsets.left
229+
230+
let presentationData = component.presentationData
231+
let helpButtonSize = self.helpButton.update(
232+
transition: transition,
233+
component: AnyComponent(PlainButtonComponent(
234+
content: AnyComponent(MultilineTextComponent(
235+
text: .plain(NSAttributedString(string: environment.strings.Login_PhoneNumberHelp, font: Font.regular(17.0), textColor: environment.theme.list.itemAccentColor))
236+
)),
237+
minSize: CGSize(width: 0.0, height: 44.0),
238+
contentInsets: UIEdgeInsets(top: 0.0, left: 8.0, bottom: 0.0, right: 8.0),
239+
action: { [weak self] in
240+
guard let self, let environment = self.environment, let controller = environment.controller() else {
241+
return
242+
}
243+
let formattedNumber = formatPhoneNumber(component.phoneNumber)
244+
let appVersion = (Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String) ?? "unknown"
245+
let systemVersion = UIDevice.current.systemVersion
246+
let region = SKPaymentQueue.default().storefront?.countryCode ?? ""
247+
let dateFormatter = DateFormatter()
248+
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss zzz"
249+
let dateString = dateFormatter.string(from: Date())
250+
251+
let body = environment.strings.Login_PhonePaidEmailBody(
252+
formattedNumber,
253+
appVersion,
254+
systemVersion,
255+
region,
256+
dateString
257+
).string
258+
259+
AuthorizationSequenceController.presentEmailComposeController(address: component.supportEmailAddress, subject: environment.strings.Login_PhonePaidEmailSubject, body: body, from: controller, presentationData: presentationData)
260+
},
261+
animateScale: false,
262+
animateContents: false
263+
)),
264+
environment: {},
265+
containerSize: CGSize(width: 200.0, height: 100.0)
266+
)
267+
let helpButtonFrame = CGRect(origin: CGPoint(x: availableSize.width - 8.0 - helpButtonSize.width, y: environment.statusBarHeight), size: helpButtonSize)
268+
if let helpButtonView = self.helpButton.view {
269+
if helpButtonView.superview == nil {
270+
self.addSubview(helpButtonView)
271+
}
272+
transition.setFrame(view: helpButtonView, frame: helpButtonFrame)
273+
}
226274

227275
let animationSize = self.animation.update(
228276
transition: transition,

0 commit comments

Comments
 (0)