添加闪退提示页面

This commit is contained in:
Fin 2023-09-18 17:05:48 +08:00
parent 8054392255
commit 6841869c3c
No known key found for this signature in database
GPG Key ID: CFB59B99D87A7B93
10 changed files with 194 additions and 11 deletions

View File

@ -93,6 +93,7 @@
0667D194247D1BA0005DE2ED /* Date+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0667D193247D1BA0005DE2ED /* Date+Extension.swift */; };
0672CB06256903F700570C9D /* MessageListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0672CB05256903F700570C9D /* MessageListViewModel.swift */; };
06787C392A710568008ABDD7 /* GesturePassTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06787C382A710568008ABDD7 /* GesturePassTextView.swift */; };
06787C3B2AB82BDB008ABDD7 /* CrashReportViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06787C3A2AB82BDB008ABDD7 /* CrashReportViewController.swift */; };
067B2EB525693E38008B6BE1 /* MessageTableViewCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 067B2EB425693E38008B6BE1 /* MessageTableViewCellViewModel.swift */; };
06802E5320ECC40C00767047 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0661A549204FDA4100965E4E /* Assets.xcassets */; };
06840DBB272298FB001B3193 /* BKColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06840DBA272298FB001B3193 /* BKColor.swift */; };
@ -268,6 +269,7 @@
0667D193247D1BA0005DE2ED /* Date+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Extension.swift"; sourceTree = "<group>"; };
0672CB05256903F700570C9D /* MessageListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListViewModel.swift; sourceTree = "<group>"; };
06787C382A710568008ABDD7 /* GesturePassTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GesturePassTextView.swift; sourceTree = "<group>"; };
06787C3A2AB82BDB008ABDD7 /* CrashReportViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReportViewController.swift; sourceTree = "<group>"; };
067B2EB425693E38008B6BE1 /* MessageTableViewCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageTableViewCellViewModel.swift; sourceTree = "<group>"; };
0683486A2050F1310024B6DA /* Bark.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Bark.entitlements; sourceTree = "<group>"; };
0683487020510FB20024B6DA /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
@ -384,6 +386,7 @@
068EC15927ED99E700D5D11E /* ServerListViewModel.swift */,
06EEF332291CCFF400CA228A /* CryptoSettingController.swift */,
06EEF334291CD00000CA228A /* CryptoSettingViewModel.swift */,
06787C3A2AB82BDB008ABDD7 /* CrashReportViewController.swift */,
);
path = Controller;
sourceTree = "<group>";
@ -975,6 +978,7 @@
0604F7DF20620D4900B32F09 /* ServerManager.swift in Sources */,
0667D192247D162C005DE2ED /* MessageTableViewCell.swift in Sources */,
0603706720E1E31600F4CA05 /* Defines.swift in Sources */,
06787C3B2AB82BDB008ABDD7 /* CrashReportViewController.swift in Sources */,
064CAB9E256BE9090018155C /* PreviewCardCellViewModel.swift in Sources */,
065BE4552565055F002A8CA4 /* HomeViewModel.swift in Sources */,
062B98C3251B2762004562E7 /* BKButton.swift in Sources */,

View File

@ -7,6 +7,7 @@
//
import CloudKit
import CrashReporter
import IceCream
import IQKeyboardManagerSwift
import Material
@ -42,22 +43,62 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
], databaseScope: .private)
#if DEBUG
let realm = try? Realm()
print("message count: \(realm?.objects(Message.self).count ?? 0)")
let realm = try? Realm()
print("message count: \(realm?.objects(Message.self).count ?? 0)")
#endif
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.black
self.window?.makeKeyAndVisible()
#if !DEBUG
let config = PLCrashReporterConfig(signalHandlerType: .mach, symbolicationStrategy: [])
if let crashReporter = PLCrashReporter(configuration: config) {
// Enable the Crash Reporter.
do {
try crashReporter.enableAndReturnError()
} catch {
print("Warning: Could not enable crash reporter: \(error)")
}
if crashReporter.hasPendingCrashReport() {
let reportController = CrashReportViewController()
do {
let data = try crashReporter.loadPendingCrashReportDataAndReturnError()
// Retrieving crash reporter data.
let report = try PLCrashReport(data: data)
if let text = PLCrashReportTextFormatter.stringValue(for: report, with: PLCrashReportTextFormatiOS) {
reportController.crashLog = text
} else {
print("CrashReporter: can't convert report to text")
}
} catch {
print("CrashReporter failed to load and parse with error: \(error)")
}
// Purge the report.
crashReporter.purgePendingCrashReport()
self.window?.rootViewController = reportController
return true
}
} else {
print("Could not create an instance of PLCrashReporter")
}
#endif
// Realm()
setupRealm()
IQKeyboardManager.shared.enable = true
self.window = UIWindow(frame: UIScreen.main.bounds)
let tabBarController = StateStorageTabBarController()
tabBarController.tabBar.tintColor = BKColor.grey.darken4
self.window?.backgroundColor = UIColor.black
self.window?.rootViewController = BarkSnackbarController(
rootViewController: tabBarController
)
@ -75,8 +116,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
viewController.tabBarItem = tabBarItems[index]
}
self.window?.makeKeyAndVisible()
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().setNotificationCategories([
UNNotificationCategory(identifier: "myNotificationCategory", actions: [
@ -154,8 +193,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
alertController.addAction(UIAlertAction(title: NSLocalizedString("CopyContent"), style: .default, handler: { _ in
if let copy = userInfo["copy"] as? String {
UIPasteboard.general.string = copy
}
else {
} else {
UIPasteboard.general.string = body
}
}))
@ -192,8 +230,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
presentedController.dismiss(animated: false) {
presentController()
}
}
else {
} else {
presentController()
}
}

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "warning@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -149,3 +149,17 @@ opensslEncodingComment = "openssl requires Hex encoding of manual keys and IVs,
ciphertextComment = "URL encoding the ciphertext, there may be special characters.";
consoleComment = "The console will print";
keyComment = "Must be %d bit long";
crashed = "Crashed!";
copyCrashLog = "Copy Crash Log";
crashContent = "If the app keeps crashing repeatedly, you can try to uncheck Bark in System Settings -> iCloud -> Apps Using iCloud. (The path may vary slightly depending on the system version.)
If the problem persists, you can try to check the FAQ to see if there is a solution.
https://bark.day.app/#/faq
If you need help, you can also send the crash log to me, and I will contact you as soon as possible.
Email: to@day.app
Telegram: https://t.me/joinchat/OsCbLzovUAE0YjY1
Github Issue: https://github.com/Finb/Bark/issues
";

View File

@ -149,3 +149,17 @@ opensslEncodingComment = "openssl, manuel anahtarların ve IV'lerin ASCII kodlam
ciphertextComment = "URL şifreli metni kodlarken özel karakterler olabilir.";
consoleComment = "Konsola şunları yazdırır";
keyComment = "%d bit uzunluğunda olmalıdır";
crashed = "Crashed!";
copyCrashLog = "Copy Crash Log";
crashContent = "If the app keeps crashing repeatedly, you can try to uncheck Bark in System Settings -> iCloud -> Apps Using iCloud. (The path may vary slightly depending on the system version.)
If the problem persists, you can try to check the FAQ to see if there is a solution.
https://bark.day.app/#/faq
If you need help, you can also send the crash log to me, and I will contact you as soon as possible.
Email: to@day.app
Telegram: https://t.me/joinchat/OsCbLzovUAE0YjY1
Github Issue: https://github.com/Finb/Bark/issues
";

View File

@ -152,3 +152,17 @@ opensslEncodingComment = "OpenSSL 要求输入的 Key 和 IV 需使用十六进
ciphertextComment = "密文可能有特殊字符,所以记得 URL 编码一下。";
consoleComment = "控制台将打印";
keyComment = "必须%d位";
crashed = "好像闪退了!";
copyCrashLog = "复制闪退日志";
crashContent = "如果一直重复闪退,你可以尝试在 系统设置 -> iCloud -> 使用iCloud的APP -> 取消勾选Bark。不同系统版本可能设置路径略有差异
如无法解决你可以尝试查看FAQ看是否有解决办法
https://bark.day.app/#/faq
如需帮助,你也可以将闪退日志反馈给我,我会尽快与你联系
邮箱: to@day.app
Telegram: https://t.me/joinchat/OsCbLzov
Github Issue: https://github.com/Finb/Bark/issues
";

View File

@ -0,0 +1,73 @@
//
// CrashReportViewController.swift
// Bark
//
// Created by huangfeng on 2023/9/18.
// Copyright © 2023 Fin. All rights reserved.
//
import UIKit
class CrashReportViewController: UIViewController {
var crashLog = ""
override func viewDidLoad() {
super.viewDidLoad()
self.overrideUserInterfaceStyle = .light
self.view.backgroundColor = UIColor.white
let warningIcon = UIImageView(image: UIImage(named: "warning"))
self.view.addSubview(warningIcon)
let crashedTitle = UILabel()
crashedTitle.text = NSLocalizedString("crashed")
crashedTitle.font = UIFont.boldSystemFont(ofSize: 30)
crashedTitle.textColor = UIColor(r255: 239, g255: 77, b255: 77)
self.view.addSubview(crashedTitle)
let contentlabel = UITextView()
contentlabel.backgroundColor = UIColor.clear
contentlabel.isEditable = false
contentlabel.dataDetectorTypes = [.link]
contentlabel.isScrollEnabled = false
contentlabel.textContainerInset = .zero
contentlabel.textContainer.lineFragmentPadding = 0
contentlabel.font = UIFont.systemFont(ofSize: 14)
contentlabel.textColor = UIColor(r255: 51, g255: 51, b255: 51)
contentlabel.text = NSLocalizedString("crashContent")
self.view.addSubview(contentlabel)
let copyButton = UIButton()
copyButton.titleLabel?.font = UIFont.boldSystemFont(ofSize: 16)
copyButton.setTitleColor(UIColor.white, for: .normal)
copyButton.setTitle(NSLocalizedString("copyCrashLog"), for: .normal)
copyButton.backgroundColor = UIColor(r255: 239, g255: 77, b255: 77)
copyButton.clipsToBounds = true
copyButton.layer.cornerRadius = 6
self.view.addSubview(copyButton)
warningIcon.snp.makeConstraints { make in
make.top.equalTo(kSafeAreaInsets.top + 60)
make.left.equalTo(15)
make.width.height.equalTo(42)
}
crashedTitle.snp.makeConstraints { make in
make.left.equalTo(warningIcon.snp.right).offset(10)
make.centerY.equalTo(warningIcon)
}
contentlabel.snp.makeConstraints { make in
make.left.equalTo(20)
make.right.equalTo(-20)
make.top.equalTo(warningIcon.snp.bottom).offset(40)
}
copyButton.snp.makeConstraints { make in
make.left.right.equalTo(contentlabel)
make.top.equalTo(contentlabel.snp.bottom).offset(40)
make.height.equalTo(44)
}
copyButton.rx.tap.subscribe { [weak self] _ in
UIPasteboard.general.string = self?.crashLog
ProgressHUD.inform(NSLocalizedString("Copy"))
}.disposed(by: rx.disposeBag)
}
}

View File

@ -28,6 +28,8 @@ def pods
pod 'Kingfisher'
pod 'MercariQRScanner', :git => 'https://github.com/Finb/QRScanner'
pod 'DropDown'
pod 'PLCrashReporter'
end
target 'Bark' do

View File

@ -28,6 +28,7 @@ PODS:
- "NSObject+Rx (5.2.2)":
- RxSwift (~> 6.2)
- ObjectMapper (4.2.0)
- PLCrashReporter (1.11.1)
- Realm (10.7.7):
- Realm/Headers (= 10.7.7)
- Realm/Headers (10.7.7)
@ -66,6 +67,7 @@ DEPENDENCIES:
- Moya/RxSwift
- "NSObject+Rx"
- ObjectMapper
- PLCrashReporter
- RxCocoa
- RxDataSources
- RxGesture
@ -92,6 +94,7 @@ SPEC REPOS:
- Moya
- "NSObject+Rx"
- ObjectMapper
- PLCrashReporter
- Realm
- RealmSwift
- RxCocoa
@ -136,6 +139,7 @@ SPEC CHECKSUMS:
Moya: 138f0573e53411fb3dc17016add0b748dfbd78ee
"NSObject+Rx": 61cf1f7306a73dcef8b36649198af0813ec18dfd
ObjectMapper: 1eb41f610210777375fa806bf161dc39fb832b81
PLCrashReporter: 5d2d3967afe0efad61b3048d617e2199a5d1b787
Realm: 8010af8b7a576ba501729bcbc54a3cd1f1f7dca3
RealmSwift: dc17e6d649c12a8996f9e962c3fe6cef356885c4
RxCocoa: 4baf94bb35f2c0ab31bc0cb9f1900155f646ba42
@ -147,6 +151,6 @@ SPEC CHECKSUMS:
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
SwiftyJSON: 2f33a42c6fbc52764d96f13368585094bfd8aa5e
PODFILE CHECKSUM: 60eda42686b4893abd7ff19557301ef40fca0dff
PODFILE CHECKSUM: 73cfda85b7a345d896330d72bc61822356f98586
COCOAPODS: 1.11.3