-
-
Notifications
You must be signed in to change notification settings - Fork 210
/
AppDelegate.cs
99 lines (85 loc) · 2.77 KB
/
AppDelegate.cs
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
namespace Sentry.Samples.Ios;
[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
public override UIWindow? Window
{
get;
set;
}
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
// Init the Sentry SDK
SentrySdk.Init(options =>
{
options.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";
options.Debug = true;
options.TracesSampleRate = 1.0;
options.ProfilesSampleRate = 1.0;
// All the native iOS SDK options are available below
// https://docs.sentry.io/platforms/apple/guides/ios/configuration/
// Enable Native iOS SDK App Hangs detection
options.Native.EnableAppHangTracking = true;
});
// create a new window instance based on the screen size
Window = new UIWindow(UIScreen.MainScreen.Bounds);
// determine the background color for the view (SystemBackground requires iOS >= 13.0)
var backgroundColor = UIDevice.CurrentDevice.CheckSystemVersion(13, 0)
#pragma warning disable CA1416
? UIColor.SystemBackground
#pragma warning restore CA1416
: UIColor.White;
// create a UIViewController with a single UILabel
var vc = new UIViewController();
vc.View!.AddSubview(new UILabel(Window!.Frame)
{
BackgroundColor = backgroundColor,
TextAlignment = UITextAlignment.Center,
Text = "Hello, iOS!",
AutoresizingMask = UIViewAutoresizing.All,
});
Window.RootViewController = vc;
// make the window visible
Window.MakeKeyAndVisible();
// Try out the Sentry SDK
SentrySdk.CaptureMessage("From iOS");
// Uncomment to try these
// throw new Exception("Test Unhandled Managed Exception");
// SentrySdk.CauseCrash(CrashType.Native);
{
var tx = SentrySdk.StartTransaction("app", "run");
var count = 10;
for (var i = 0; i < count; i++)
{
FindPrimeNumber(100000);
}
tx.Finish();
}
return true;
}
private static long FindPrimeNumber(int n)
{
int count = 0;
long a = 2;
while (count < n)
{
long b = 2;
int prime = 1;// to check if found a prime
while (b * b <= a)
{
if (a % b == 0)
{
prime = 0;
break;
}
b++;
}
if (prime > 0)
{
count++;
}
a++;
}
return (--a);
}
}