130 lines
4.0 KiB
Mathematica
130 lines
4.0 KiB
Mathematica
![]() |
//
|
||
|
// AppDelegate.m
|
||
|
// YUMI
|
||
|
//
|
||
|
// Created by admin on 2023/3/9.
|
||
|
//
|
||
|
|
||
|
#import "AppDelegate.h"
|
||
|
#import "TabbarRegardGovernancer.h"
|
||
|
#import "BaseNevigationGovernancer.h"
|
||
|
#import "AppDelegate+ThirdConfig.h"
|
||
|
#import <NIMSDK/NIMSDK.h>
|
||
|
#import <UMCommon/UMCommon.h>
|
||
|
@interface AppDelegate ()
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation AppDelegate
|
||
|
|
||
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||
|
TabbarRegardGovernancer *vc = [[TabbarRegardGovernancer alloc] init];
|
||
|
BaseNevigationGovernancer *bnc = [[BaseNevigationGovernancer alloc] initWithRootViewController:vc];
|
||
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||
|
self.window.rootViewController = bnc;
|
||
|
[self.window makeKeyAndVisible];
|
||
|
|
||
|
[self setupLaunchADRegard];
|
||
|
|
||
|
[self initTertiusDisposition];
|
||
|
|
||
|
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"kYouMinumbernnagna"]) {
|
||
|
|
||
|
[UMConfigure initWithAppkey:@"6434c6dfd64e686139618269" channel:@"yumi_appstore"];
|
||
|
}
|
||
|
return YES;
|
||
|
}
|
||
|
|
||
|
|
||
|
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||
|
NSInteger count = [NIMSDK sharedSDK].conversationManager.allUnreadCount;
|
||
|
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:count];
|
||
|
}
|
||
|
|
||
|
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
||
|
|
||
|
[[NIMSDK sharedSDK] updateApnsToken:deviceToken];
|
||
|
}
|
||
|
|
||
|
|
||
|
#pragma mark - Core Data stack
|
||
|
@synthesize managedObjectContext = _managedObjectContext;
|
||
|
@synthesize managedObjectModel = _managedObjectModel;
|
||
|
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
|
||
|
|
||
|
-(NSURL *)aplictowardsionlictowardsionDocumentsDirectoryvisory{
|
||
|
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
|
||
|
}
|
||
|
|
||
|
- (NSManagedObjectModel *)managedObjectModel {
|
||
|
|
||
|
if (_managedObjectModel != nil) {
|
||
|
return _managedObjectModel;
|
||
|
}
|
||
|
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"_1_______" withExtension:@"momd"];
|
||
|
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
|
||
|
return _managedObjectModel;
|
||
|
}
|
||
|
|
||
|
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
|
||
|
|
||
|
if (_persistentStoreCoordinator != nil) {
|
||
|
return _persistentStoreCoordinator;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
|
||
|
NSURL *storeURL = [[self aplictowardsionlictowardsionDocumentsDirectoryvisory] URLByAppendingPathComponent:@"_1_______.sqlite"];
|
||
|
NSError *error = nil;
|
||
|
NSString *failureReason = @"There was an error creating or loading the application's saved data.";
|
||
|
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
|
||
|
|
||
|
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||
|
dict[NSLocalizedDescriptionKey] = @"Failed to initialize the application's saved data";
|
||
|
dict[NSLocalizedFailureReasonErrorKey] = failureReason;
|
||
|
dict[NSUnderlyingErrorKey] = error;
|
||
|
error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:9999 userInfo:dict];
|
||
|
|
||
|
|
||
|
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
|
||
|
abort();
|
||
|
}
|
||
|
|
||
|
return _persistentStoreCoordinator;
|
||
|
}
|
||
|
|
||
|
|
||
|
- (NSManagedObjectContext *)managedObjectContext {
|
||
|
|
||
|
if (_managedObjectContext != nil) {
|
||
|
return _managedObjectContext;
|
||
|
}
|
||
|
|
||
|
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
|
||
|
if (!coordinator) {
|
||
|
return nil;
|
||
|
}
|
||
|
_managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
|
||
|
[_managedObjectContext setPersistentStoreCoordinator:coordinator];
|
||
|
return _managedObjectContext;
|
||
|
}
|
||
|
|
||
|
#pragma mark - Core Data Saving support
|
||
|
|
||
|
- (void)preserveConessay {
|
||
|
NSManagedObjectContext *managedObjectContext = self.managedObjectContext;
|
||
|
if (managedObjectContext != nil) {
|
||
|
NSError *error = nil;
|
||
|
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
|
||
|
|
||
|
|
||
|
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
|
||
|
abort();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
@end
|