-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAppDelegate.swift
More file actions
35 lines (30 loc) · 1.18 KB
/
AppDelegate.swift
File metadata and controls
35 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if let controller = window?.rootViewController as? FlutterViewController {
let batteryChannel = FlutterMethodChannel(
name: "app.sentrymobile.io/nativeCrash",
binaryMessenger: controller.binaryMessenger
)
batteryChannel.setMethodCallHandler {
[weak self] call, result in
if call.method == "crashSwift" {
self?.crashSwift()
} else if call.method == "crashObjectiveC" {
NativeCrashObjectiveC.crashingFunction()
}
}
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
private func crashSwift() {
let string: String? = nil
print(string!.size) // Force-unwrapping a nil optional crashes the app.
}
}