|
@@ -0,0 +1,85 @@
|
|
|
|
|
+#import <UIKit/UIKit.h>
|
|
|
|
|
+#import <Foundation/Foundation.h>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@interface TweakHelper : NSObject
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
++ (instancetype)sharedInstance;
|
|
|
|
|
+
|
|
|
|
|
++ (void)sendMsgWithTitle:(NSString *)title text:(NSString *)text;
|
|
|
|
|
+
|
|
|
|
|
++ (BOOL)canOpenSileo;
|
|
|
|
|
++ (BOOL)canOpenCydia;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+@end
|
|
|
|
|
+
|
|
|
|
|
+@implementation TweakHelper
|
|
|
|
|
+
|
|
|
|
|
+static TweakHelper *sharedInstance = nil;
|
|
|
|
|
+
|
|
|
|
|
++ (instancetype)sharedInstance {
|
|
|
|
|
+ static dispatch_once_t onceToken;
|
|
|
|
|
+ dispatch_once(&onceToken, ^{
|
|
|
|
|
+ if (!sharedInstance) {
|
|
|
|
|
+ sharedInstance = [[self alloc] init];
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return sharedInstance;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (void)sendMsgWithTitle:(NSString *)title text:(NSString *)text {
|
|
|
|
|
+ NSString * appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
|
|
|
|
+ NSString * appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
|
|
|
|
|
+ NSString * systemVersion = [[UIDevice currentDevice] systemVersion];
|
|
|
|
|
+ NSString * deviceName = [[UIDevice currentDevice] name];
|
|
|
|
|
+ NSString * jailbreak = ([TweakHelper canOpenSileo] || [TweakHelper canOpenCydia]) ? @"已越狱": @"未越狱";
|
|
|
|
|
+ NSString *customText = [NSString stringWithFormat:@"- %@(v%@) \n > - %@(iOS%@) \n > - Jailbroken(%@) \n >", appName, appVersion, deviceName, systemVersion, jailbreak];
|
|
|
|
|
+ if (text.length > 0) {
|
|
|
|
|
+ customText = [NSString stringWithFormat:@"%@ - %@",customText,text];
|
|
|
|
|
+ }
|
|
|
|
|
+ NSString *content = [NSString stringWithFormat:@"#### %@ \n > %@ \n", title, customText];
|
|
|
|
|
+ NSURLSession *session = [NSURLSession sharedSession];
|
|
|
|
|
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://oapi.dingtalk.com/robot/send?access_token=8b631458ca65b9181b87869d138caddf1ef14eddf02a5032a49bef2bef098295"]];
|
|
|
|
|
+ request.HTTPMethod = @"POST";
|
|
|
|
|
+ [request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
|
|
|
|
|
+ NSDictionary *message = @{
|
|
|
|
|
+ @"msgtype": @"markdown",
|
|
|
|
|
+ @"markdown": @{
|
|
|
|
|
+ @"title": @"[ABox服务端]",
|
|
|
|
|
+ @"text": content
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:message options:0 error:nil];
|
|
|
|
|
+ request.HTTPBody = jsonData;
|
|
|
|
|
+ NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
|
|
|
|
|
+ if (error) {
|
|
|
|
|
+ NSLog(@"Error: %@", error);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ NSString *responseData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
|
|
|
+ NSLog(@"Response: %@", responseData);
|
|
|
|
|
+ }
|
|
|
|
|
+ }];
|
|
|
|
|
+ [task resume];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (BOOL)canOpenSileo {
|
|
|
|
|
+ UIApplication *application = [UIApplication sharedApplication];
|
|
|
|
|
+ if ([application canOpenURL:[NSURL URLWithString:@"sileo://source/https://repo.abox.plus/"]]) {
|
|
|
|
|
+ return YES;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return NO;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
++ (BOOL)canOpenCydia {
|
|
|
|
|
+ UIApplication *application = [UIApplication sharedApplication];
|
|
|
|
|
+ if ([application canOpenURL:[NSURL URLWithString:@"cydia://url/https://cydia.saurik.com/api/share#?source=https://repo.abox.plus/"]]) {
|
|
|
|
|
+ return YES;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return NO;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+@end
|