123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- //
- // AppDelegate.m
- // ComPDFKit
- //
- // Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
- //
- // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
- // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
- // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
- // This notice may not be removed from this file.
- //
- #import "AppDelegate.h"
- #import <ComPDFKit/ComPDFKit.h>
- #import <compdfkit_tools/compdfkit_tools.h>
- #import "CPDFViewController.h"
- #import "XMLParseManager.h"
- static AppDelegate *appDelegate = NULL;
- @interface AppDelegate ()
- @property (nonatomic, strong) UIWindow *window;
- @property (nonatomic, strong) XMLParseManager *manager;
- @end
- @implementation AppDelegate
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- // Override point for customization after application launch.
- NSString *path = [[NSBundle mainBundle]pathForResource:@"SDKLicense" ofType:@"xml"];
- NSURL *url = [NSURL fileURLWithPath:path];
- _manager = [[XMLParseManager alloc]init];
- [_manager parseXMLWithURL:url completion:^(BOOL SUC, XPDXMLElement *data,NSError *error) {
- if (SUC) {
- NSDictionary * attribute = data.attribute;
- NSString * key = attribute[@"key"];
- NSString * secret = attribute[@"secret"];
- [CPDFKit setLicenseKey:key secret:secret];
-
- if (@available(iOS 13.0, *)) {
-
- } else {
- UIWindow *windows = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- [self configWindow:windows];
- }
-
- }else{
- NSLog(@"error = %@",error);
- }
- }];
- return YES;
- }
- - (void)configWindow:(UIWindow *)window {
- self.window = window;
- self.window.backgroundColor = [UIColor whiteColor];
-
- NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Quick Start Guide" ofType:@"pdf"];
- NSString *documentFolder = [NSHomeDirectory() stringByAppendingFormat:@"/%@/%@", @"Documents",@"Samples"];
- if (![[NSFileManager defaultManager] fileExistsAtPath:documentFolder])
- [[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:documentFolder] withIntermediateDirectories:YES attributes:nil error:nil];
-
- NSString * documentPath = [documentFolder stringByAppendingPathComponent:filePath.lastPathComponent];
- if (![[NSFileManager defaultManager] fileExistsAtPath:documentPath])
- [[NSFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:filePath] toURL:[NSURL fileURLWithPath:documentPath] error:nil];
-
- CPDFViewController *pdfViewController = [[CPDFViewController alloc] initWithFilePath:documentPath password:nil];
- CNavigationController *navController = [[CNavigationController alloc]initWithRootViewController:pdfViewController];
- self.window.rootViewController = navController;
-
- [self.window makeKeyAndVisible];
- }
- + (AppDelegate *)sharedAppDelegate {
- if (!appDelegate)
- appDelegate = [[AppDelegate alloc] init];
-
- return appDelegate;
- }
- #pragma mark - UISceneSession lifecycle
- - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
- // Called when a new scene session is being created.
- // Use this method to select a configuration to create the new scene with.
- return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
- }
- - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
- // Called when the user discards a scene session.
- // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
- // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
- }
- @end
|