-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTweak.xm
More file actions
59 lines (44 loc) · 2.08 KB
/
Tweak.xm
File metadata and controls
59 lines (44 loc) · 2.08 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#import <UIKit/UIKit.h>
static UIViewController *_topMostController(UIViewController *cont) {
UIViewController *topController = cont;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
if ([topController isKindOfClass:[UINavigationController class]]) {
UIViewController *visible = ((UINavigationController *)topController).visibleViewController;
if (visible) {
topController = visible;
}
}
return (topController != cont ? topController : nil);
}
static UIViewController *topMostController() {
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *next = nil;
while ((next = _topMostController(topController)) != nil) {
topController = next;
}
return topController;
}
%hook UIApplication
-(void)finishedTest:(id)arg1 extraResults:(id)arg2 {
%orig;
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"FirstLaunch"]) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Hola" message:@"nil" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *twitter = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// Open URL
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"https://twitter.com/ajbbocydia"] options:@{} completionHandler:nil];
// // // //
[[NSUserDefaults standardUserDefaults] setValue:@"AlreadyLaunch" forKey:@"FirstLaunch"];
[[NSUserDefaults standardUserDefaults] synchronize];
}];
UIAlertAction *dismiss = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[[NSUserDefaults standardUserDefaults] setValue:@"AlreadyLaunch" forKey:@"FirstLaunch"];
[[NSUserDefaults standardUserDefaults] synchronize];
}];
[alert addAction:twitter];
[alert addAction:dismiss];
[topMostController() presentViewController:alert animated:true completion:nil];
}
}
%end