AppDelegate.m 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. //
  2. // AppDelegate.m
  3. // aiim
  4. //
  5. // Created by gan on 2025/2/27.
  6. //
  7. #import "AppDelegate.h"
  8. #import "UDManager.h"
  9. #import <UserNotifications/UserNotifications.h>
  10. #import <PushKit/PushKit.h>
  11. #import "CallKit/CallKit.h"
  12. #import "UserNetApi.h"
  13. #import "CryptoAES.h"
  14. #import "GWebSocket.h"
  15. #import "GDBManager.h"
  16. #import "APPLocker.h"
  17. #import "JSGController.h"
  18. #import "LoginStateManager.h"
  19. #import "FloatingWindow.h"
  20. #import "ChatIndexController.h"
  21. #import "ChatController.h"
  22. #import "ChatListStore.h"
  23. #import "ChatsStore.h"
  24. #import "OSSManager.h"
  25. #import <Bugly/Bugly.h>
  26. #ifdef DEBUG
  27. #import <DoraemonKit/DoraemonManager.h>
  28. #endif
  29. @import JitsiMeetSDK;
  30. @interface AppDelegate ()<UNUserNotificationCenterDelegate,PKPushRegistryDelegate,CXProviderDelegate>
  31. @property (nonatomic, strong) CXProvider *callProvider;
  32. @property (nonatomic) NSUUID *uuid;
  33. @property (nonatomic) NSDictionary *msg;
  34. @property (strong, nonatomic) NSString *bgMark;
  35. @property (strong, nonatomic) FloatingWindow *floatWindow;
  36. @property (nonatomic, strong) JSGController * _Nullable jsyuyinctr;
  37. @property (nonatomic) BOOL isNotification;
  38. @property (nonatomic, assign) NSInteger badgeCount;
  39. @property (nonatomic, assign) NSInteger addFriendBadgeCount;
  40. @end
  41. @implementation AppDelegate
  42. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  43. // Override point for customization after application launch.
  44. app = self;
  45. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  46. self.window.backgroundColor = UIColor.blackColor;
  47. BOOL isLoggedIn = [LoginStateManager sharedManager].isLoggedIn;
  48. if (isLoggedIn) {
  49. [self initDataAfterLogin:YES];
  50. } else {
  51. [self openLoginController];
  52. }
  53. [self.window makeKeyAndVisible];
  54. BuglyConfig *config = [[BuglyConfig alloc] init];
  55. config.reportLogLevel = BuglyLogLevelVerbose;
  56. [Bugly startWithAppId:@"1d9e6b546a" config:config];
  57. self.isJitsiMeet=false;
  58. _isNotification=false;
  59. self.shouldShowLock = YES;
  60. self.bgMark=@"";
  61. [self initJSMSDK];
  62. [self setupListener];
  63. [self registerPushright];
  64. [self setupCallProvider];
  65. _floatWindow = [[FloatingWindow alloc] initWithFrame:self.window.bounds];
  66. [_floatWindow hide];
  67. self.bgMark = @"";
  68. NSLog(@"didFinishLaunchingWithOptions------");
  69. AVAudioSession *session = [AVAudioSession sharedInstance];
  70. [session setCategory:AVAudioSessionCategoryPlayAndRecord mode:AVAudioSessionModeVoiceChat options:AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionAllowBluetoothA2DP | AVAudioSessionCategoryOptionAllowAirPlay error:nil];
  71. [session setActive:YES error:nil];
  72. #ifdef DEBUG
  73. //默认
  74. [[DoraemonManager shareInstance] install];
  75. // 或者使用传入位置,解决遮挡关键区域,减少频繁移动
  76. //[[DoraemonManager shareInstance] installWithStartingPosition:CGPointMake(66, 66)];
  77. #endif
  78. return YES;
  79. }
  80. -(void)applicationDidBecomeActive:(UIApplication *)application{
  81. NSLog(@"applicationDidBecomeActive");
  82. if(self.isLogin){
  83. if(self.isJitsiMeet){
  84. [_floatWindow viewInFload:0];
  85. }
  86. [self showLockScreen];
  87. if(!_isNotification){
  88. if ([[self.window jk_currentViewController] isKindOfClass:UITabBarController.class]){
  89. UITabBarController * tabbarVc= (UITabBarController *)[self.window jk_currentViewController];
  90. if (tabbarVc.selectedIndex==0) {
  91. ChatIndexController * chatListVc = tabbarVc.viewControllers[0];
  92. if (chatListVc) {
  93. [chatListVc reloadList];
  94. }
  95. }
  96. }
  97. else{
  98. [Bugly reportException:[NSException exceptionWithName:@"applicationDidBecomeActive1" reason:@"1" userInfo:nil]];
  99. if ([[self.window jk_currentViewController] isKindOfClass:ChatController.class]) {
  100. ChatController * currentChatVc = (ChatController *)[self.window jk_currentViewController];
  101. [currentChatVc reloadAllData];
  102. [Bugly reportException:[NSException exceptionWithName:@"applicationDidBecomeActive2" reason:@"2" userInfo:nil]];
  103. }
  104. }
  105. }
  106. }
  107. }
  108. -(void)applicationDidEnterBackground:(UIApplication *)application{
  109. NSLog(@"applicationDidEnterBackground");
  110. _isNotification=false;
  111. // [self endWebsocket];
  112. __block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
  113. [application endBackgroundTask:bgTask];
  114. bgTask = UIBackgroundTaskInvalid;
  115. }];
  116. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  117. // 在这里保持任务运行或等待事件,例如等待来电等。
  118. [application endBackgroundTask:bgTask];
  119. bgTask = UIBackgroundTaskInvalid;
  120. });
  121. // 应用进入后台时标记需要显示锁屏
  122. if(self.isJitsiMeet == YES){
  123. [self.window endEditing:YES];
  124. }
  125. else{
  126. if ([[APPLocker sharedLocker] isPasswordSet] && [[APPLocker sharedLocker] isLockEnabled]) {
  127. self.shouldShowLock = YES;
  128. }
  129. }
  130. }
  131. + (instancetype)sharedInstance {
  132. return app;
  133. }
  134. -(void)initJSMSDK{
  135. JitsiMeetConferenceOptions *defaultOptions
  136. = [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder *builder) {
  137. builder.serverURL = [NSURL URLWithString:JitsiMeetSV];
  138. [builder setFeatureFlag:@"welcomepage.enabled" withBoolean:NO];
  139. [builder setFeatureFlag:@"prejoinPage.enabled" withBoolean:NO];
  140. //媒体流优化
  141. builder.audioMuted = NO; // 提前初始化音频模块
  142. builder.videoMuted = NO; // 提前初始化视频模块
  143. //禁用非必要功能(减少初始化负载)
  144. [builder setFeatureFlag:@"add-people.enabled" withBoolean:NO];
  145. [builder setFeatureFlag:@"invite.enabled" withBoolean:NO];
  146. [builder setFeatureFlag:@"live-streaming.enabled" withBoolean:NO];
  147. [builder setFeatureFlag:@"video-share.enabled" withBoolean:NO];
  148. [builder setFeatureFlag:@"call-integration.enabled" withBoolean:NO];
  149. [builder setFeatureFlag:@"startWithAudioMuted" withBoolean:NO];
  150. [builder setFeatureFlag:@"recording.enabled" withBoolean:NO];
  151. [builder setFeatureFlag:@"kick-out.enabled" withBoolean:NO];
  152. [builder setFeatureFlag:@"security-options.enabled" withBoolean:NO];
  153. //
  154. // //网络传输层加速
  155. // [builder setConfigOverride:@"disableSimulcast" withBoolean:YES];
  156. // [builder setFeatureFlag:@"reconnect.enabled" withBoolean:YES];
  157. // [builder setFeatureFlag:@"websocket-keep-alive.enabled" withBoolean:YES];
  158. // [builder setFeatureFlag:@"network-monitor.enabled" withBoolean:YES];
  159. // [builder setConfigOverride:@"iceTransportPolicy" withValue:@"relay"];
  160. // // 界面渲染加速
  161. // [builder setFeatureFlag:@"filmstrip.enabled" withBoolean:NO];
  162. // [builder setFeatureFlag:@"tile-view.enabled" withBoolean:NO];
  163. //
  164. // [builder setFeatureFlag:@"pip.enabled" withBoolean:NO];
  165. // [builder setFeatureFlag:@"chat.enabled" withBoolean:NO];
  166. [builder setConfigOverride:@"toolbarButtons" withArray:@[@"microphone",@"camera"]];
  167. }];
  168. [JitsiMeet sharedInstance].defaultConferenceOptions = defaultOptions;
  169. UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
  170. _jsyuyinctr = [board instantiateViewControllerWithIdentifier:@"JSGController"];
  171. _jsyuyinctr.modalPresentationStyle = UIModalPresentationFullScreen;
  172. }
  173. -(void)setupListener{
  174. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onLoginSucc) name:nkonLoginSucc object:nil];
  175. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onLogout) name:nkonLogoutSucc object:nil];
  176. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addFriend) name:nkonAddFriendNote object:nil];
  177. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJoinGroupNote:) name:nkonJoinGroupNote object:nil];
  178. }
  179. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
  180. NSLog(@"Failed to get token, error: %@", error);
  181. }
  182. #pragma mark push token voip token
  183. -(void)registerPushright{
  184. // 请求推送权限
  185. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  186. center.delegate = self; // 设置代理以处理通知相关事件
  187. [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionProvidesAppNotificationSettings) completionHandler:^(BOOL granted, NSError * _Nullable error) {
  188. if (granted) {
  189. // 用户授权成功
  190. dispatch_async(dispatch_get_main_queue(), ^{
  191. [[UIApplication sharedApplication] registerForRemoteNotifications];
  192. });
  193. } else {
  194. // 用户授权失败
  195. }
  196. }];
  197. PKPushRegistry *registry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()];
  198. registry.delegate = self;
  199. registry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP];
  200. }
  201. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  202. // 将NSData转换为NSString以便于传输或存储
  203. NSRange range = NSMakeRange(0, 16); // 例如,从索引0开始,获取前10个字节
  204. NSData *subData1 = [deviceToken subdataWithRange:range];
  205. range = NSMakeRange(16, 16);
  206. NSData *subData2 = [deviceToken subdataWithRange:range];
  207. range = NSMakeRange(24, 32);
  208. NSString *token1=[[subData1 description] substringWithRange:range];
  209. NSString *token2=[[subData2 description] substringWithRange:range];
  210. NSString *token = [NSString stringWithFormat:@"%@%@",token1,token2];
  211. NSLog(@"%@",token);
  212. // 将token发送到你的服务器或其他需要的地方
  213. [UDManager.shareInstance setSDManager:token key:dkpushtoken];
  214. NSString *bgMark = [NSString stringWithFormat:@"推送token:%ld",token.length];
  215. [Bugly reportException:[NSException exceptionWithName:bgMark reason:@"" userInfo:nil]];
  216. if(self.isLogin){
  217. [self updivicetoken];
  218. }
  219. }
  220. -(void)updivicetoken{
  221. NSString *token =[UDManager.shareInstance getSDManager:dkpushtoken];
  222. NSDictionary *usinfo = [UDManager.shareInstance getDDManager:dkuserinfo];
  223. NSLog(@"dkpushtoken:%@",token);
  224. NSDictionary *ud=@{
  225. @"registrationId": token?:@"",
  226. @"userId":usinfo[@"id"]?:@"",
  227. @"platformType":@"i"
  228. };
  229. NSString *bgMark = [NSString stringWithFormat:@"上传推送token:%ld",token.length];
  230. [Bugly reportException:[NSException exceptionWithName:bgMark reason:@"" userInfo:nil]];
  231. [UserNetApi setUserinfo:ud succ:^(int code, NSDictionary * res) {
  232. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:res options:0 error:nil];
  233. if (!jsonData) {
  234. NSLog(@"Got an error:");
  235. } else {
  236. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  237. NSLog(@"%@", jsonString); // 输出:{"name":"John","age":25}
  238. }
  239. } fail:^(NSError * _Nonnull error) {
  240. NSLog(@"--%@",error);
  241. }];
  242. }
  243. -(void)updiviceVoIPtoken{
  244. NSString *token =[UDManager.shareInstance getSDManager:dkvoiptoken];
  245. NSDictionary *usinfo = [UDManager.shareInstance getDDManager:dkuserinfo];
  246. NSLog(@"dkvoiptoken:%@",token);
  247. NSString *bgMark = [NSString stringWithFormat:@"上传 voip 推送token:%ld",token.length];
  248. [Bugly reportException:[NSException exceptionWithName:bgMark reason:@"" userInfo:nil]];
  249. if([token isKindOfClass:[NSNull class]]){
  250. return;
  251. }
  252. NSDictionary *ud=@{
  253. @"voipTk": token?:@"",
  254. @"userId":usinfo[@"id"]?:@"",
  255. @"platformType":@"i"
  256. };
  257. [UserNetApi setUserinfo:ud succ:^(int code, NSDictionary * res) {
  258. NSLog(@"updiviceVoIPtoken:%@",[res description]);
  259. } fail:^(NSError * _Nonnull error) {
  260. NSLog(@"--%@",error);
  261. }];
  262. }
  263. - (void)addFriend{
  264. self.addFriendBadgeCount++;
  265. NSLog(@"addFriend------------:%ld", self.addFriendBadgeCount);
  266. [self updateTabBarBadgeValueAtIndex:1 badgeCount:self.addFriendBadgeCount];
  267. [self sendAddFreindNotice];
  268. [self updateApplicationIconBadgeNumber];
  269. }
  270. - (void)sendAddFreindNotice {
  271. NSInteger total = self.badgeCount + self.addFriendBadgeCount + 1;
  272. UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
  273. content.title = @"好友申请";
  274. content.body = @"您收到了新的好友申请";
  275. content.sound = [UNNotificationSound defaultSound];
  276. content.badge = @(total);
  277. content.userInfo = @{
  278. @"need_present":@(1)
  279. };
  280. [self addNotificationRequest:content];
  281. }
  282. - (void)onJoinGroupNote:(NSNotification *)notice {
  283. NSDictionary *dict = notice.object;
  284. if (![dict isKindOfClass:NSDictionary.class]) {
  285. return;
  286. }
  287. NSInteger total = self.badgeCount + self.addFriendBadgeCount + 1;
  288. UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
  289. content.title = @"Uim消息";
  290. content.body = dict[@"content"] ?: @"您有一条新消息";
  291. content.sound = [UNNotificationSound defaultSound];
  292. content.badge = @(total);
  293. content.userInfo = @{
  294. @"need_present":@(1)
  295. };
  296. [self addNotificationRequest:content];
  297. }
  298. - (void)addNotificationRequest:(UNMutableNotificationContent *)content {
  299. NSString *identifier = [NSString stringWithFormat:@"FriendRequest_%@", [[NSUUID UUID] UUIDString]];
  300. UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil];
  301. [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
  302. if (error) {
  303. NSLog(@"发送本地通知失败: %@", error);
  304. } else {
  305. NSLog(@"发送本地通知成功");
  306. }
  307. }];
  308. }
  309. - (void)updateApplicationIconBadgeNumber {
  310. NSInteger total = self.badgeCount + self.addFriendBadgeCount;
  311. if (@available(iOS 16.0, *)) {
  312. [[UNUserNotificationCenter currentNotificationCenter] setBadgeCount:total withCompletionHandler:^(NSError * _Nullable error) {
  313. if (error) {
  314. NSLog(@"设置消息未读数 error: %@", error);
  315. }
  316. }];
  317. } else {
  318. // Fallback on earlier versions
  319. [[UIApplication sharedApplication] setApplicationIconBadgeNumber:total];
  320. }
  321. }
  322. - (void)resetAddFriendBadgeCount {
  323. self.addFriendBadgeCount = 0;
  324. [self updateTabBarBadgeValueAtIndex:1 badgeCount:0];
  325. [self updateApplicationIconBadgeNumber];
  326. }
  327. - (void)resetBadgeCount {
  328. self.badgeCount = 0;
  329. [self updateApplicationIconBadgeNumber];
  330. }
  331. - (void)updateTabBarBadgeValueAtIndex:(NSInteger)index badgeCount:(NSInteger)badgeCount {
  332. UITabBarController * tabbarVc = (UITabBarController *)self.window.rootViewController;
  333. if (![tabbarVc isKindOfClass:[UITabBarController class]]) {
  334. return;
  335. }
  336. if(index < 0 || index >= tabbarVc.tabBar.items.count){
  337. return;
  338. }
  339. UITabBarItem *tabBarItem = tabbarVc.tabBar.items[index];
  340. NSString *badgeValue = badgeCount > 0 ? [NSString stringWithFormat:@"%ld", badgeCount] : nil;
  341. badgeValue = badgeValue.length > 2 ? @"99+" : badgeValue;
  342. tabBarItem.badgeValue = badgeValue;
  343. }
  344. - (void)updateBadgeCount:(NSInteger)badgeCount {
  345. self.badgeCount = badgeCount;
  346. [self updateApplicationIconBadgeNumber];
  347. }
  348. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  349. NSLog(@"Received notification: %@", userInfo);
  350. NSDictionary *temp =userInfo[@"imMsg"];
  351. if(temp){
  352. if ([temp jk_hasKey:@"addFriend"]) {
  353. [self addFriend];
  354. }
  355. NSDictionary *msg =temp[@"message"];
  356. NSString *msgtype=msg[@"msgtype"];
  357. if([msgtype isEqualToString:@"close"]){
  358. if(self.uuid!=nil){
  359. NSString *fromId = self.msg[@"fromId"];
  360. if ( [fromId isEqualToString:msg[@"fromId"]]) {
  361. [self.callProvider reportCallWithUUID:self.uuid endedAtDate:nil reason:CXCallEndedReasonDeclinedElsewhere];
  362. self.uuid = nil;
  363. self.msg =nil;
  364. }
  365. }
  366. }
  367. }
  368. // 处理推送消息,例如更新UI或处理数据等
  369. completionHandler(UIBackgroundFetchResultNewData);
  370. }
  371. #pragma mark - PKPushRegistryDelegate
  372. - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
  373. // 处理推送凭证更新,例如保存 token 到服务器
  374. NSLog(@"Credentials updated: %@", credentials.token);
  375. NSData *deviceToken = (NSData *)credentials.token;
  376. NSRange range = NSMakeRange(0, 16); // 例如,从索引0开始,获取前10个字节
  377. NSData *subData1 = [deviceToken subdataWithRange:range];
  378. range = NSMakeRange(16, 16);
  379. NSData *subData2 = [deviceToken subdataWithRange:range];
  380. range = NSMakeRange(24, 32);
  381. //NSLog(@"subData1: %@",subData1);
  382. //NSLog(@"subData2: %@",subData2);
  383. NSString *token1=[[subData1 description] substringWithRange:range];
  384. NSString *token2=[[subData2 description] substringWithRange:range];
  385. NSString *token = [NSString stringWithFormat:@"%@%@",token1,token2];
  386. NSLog(@"%@",token);
  387. //将token发送到你的服务器或其他需要的地方
  388. NSString *bgMark = [NSString stringWithFormat:@"voip token:%ld",token.length];
  389. [Bugly reportException:[NSException exceptionWithName:bgMark reason:@"" userInfo:nil]];
  390. [UDManager.shareInstance setSDManager:token key:dkvoiptoken];
  391. if(self.isLogin){
  392. [self updiviceVoIPtoken];
  393. }
  394. }
  395. - (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion{
  396. NSDictionary * temp =payload.dictionaryPayload;
  397. temp =temp[@"business"];
  398. temp=temp[@"incomingCallParams"];
  399. NSString *name =temp[@"localizedCallerName"];
  400. NSLog(@"name:%@",name);
  401. temp =payload.dictionaryPayload;
  402. temp =temp[@"imMsg"];
  403. if(self.uuid!=nil||self.isJitsiMeet){//通知对方正忙,功能需要补上
  404. [self isBUSYNow:temp[@"message"]];
  405. return;
  406. }
  407. self.msg = temp[@"message"];
  408. NSLog(@"self.msg-----:%@",self.msg);
  409. CXCallUpdate * callUpdate = [[CXCallUpdate alloc]init];
  410. callUpdate.supportsGrouping = YES;
  411. callUpdate.supportsDTMF = YES;
  412. callUpdate.hasVideo = YES;
  413. callUpdate.supportsHolding = YES;
  414. [callUpdate setLocalizedCallerName:name];
  415. CXHandle * handle = [[CXHandle alloc]initWithType:CXHandleTypePhoneNumber value:@""];
  416. callUpdate.remoteHandle = handle;
  417. self.uuid = [NSUUID UUID];
  418. [self.callProvider reportNewIncomingCallWithUUID:self.uuid update:callUpdate completion:^(NSError * _Nullable error) {
  419. NSLog(@"%@",error);
  420. }];
  421. completion();
  422. }
  423. -(void)isBUSYNow:(NSDictionary *)msg{
  424. NSDate *now = [NSDate date];
  425. NSTimeInterval trt = [now timeIntervalSince1970];
  426. NSInteger time = trt*1000;
  427. NSString *strtime = [NSString stringWithFormat:@"%ld",(long)time];
  428. NSDictionary *callMsg = @{
  429. @"code":SendCode_WEBRTC_DFBUSY,
  430. @"message": @{
  431. @"chatId":msg[@"fromId"],
  432. @"fromId":msg[@"chatId"],
  433. @"type":@"0",
  434. @"messageType":MessageType_DFBUSY,
  435. @"timestamp":strtime,
  436. @"payload":@""
  437. }
  438. };
  439. NSError *error;
  440. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:callMsg options:0 error:&error];
  441. if (!jsonData) {
  442. NSLog(@"Got an error: %@", error);
  443. } else {
  444. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  445. NSLog(@"%@", jsonString); // 输出: {"name":"John","age":25}
  446. [GWebSocket.shareInstance sendMsg:jsonString];
  447. }
  448. }
  449. #pragma mark - CXProviderDelegate Methods
  450. - (void)setupCallProvider {
  451. // 创建配置对象
  452. CXProviderConfiguration *config = [[CXProviderConfiguration alloc] init];
  453. config.supportsVideo = YES; // 是否支持视频通话
  454. config.maximumCallGroups = 1; // 最大通话组数
  455. config.maximumCallsPerCallGroup = 1; // 每个通话组的最大通话数
  456. config.supportedHandleTypes = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:CXHandleTypeGeneric],[NSNumber numberWithInt:CXHandleTypePhoneNumber], nil];//[NSSet setWithArray:@[CXHandleTypePhoneNumber]]; // 支持的号码类型
  457. config.iconTemplateImageData = UIImagePNGRepresentation([UIImage imageNamed:@"AppIcon"]); // 应用图标
  458. config.ringtoneSound = @"ringtone.aiff"; // 铃声文件(可选)
  459. // 创建CXProvider实例
  460. self.callProvider = [[CXProvider alloc] initWithConfiguration:config];
  461. [self.callProvider setDelegate:self queue:nil];
  462. //self.callRoomMap = [NSMutableDictionary dictionary];
  463. }
  464. - (void)providerDidReset:(CXProvider *)provider {
  465. NSLog(@"Provider reset");
  466. }
  467. - (void)provider:(CXProvider *)provider performStartCallAction:(CXStartCallAction *)action {
  468. // 开始通话的逻辑,如连接服务器等
  469. NSLog(@"performStartCallAction:%@",action);
  470. [action fulfill]; // 当通话开始时调用此方法完成action
  471. }
  472. -(void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action{
  473. [self reciveVoip];
  474. //使用GCD创建一个在3秒后执行的定时器
  475. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  476. NSLog(@"performAnswerCallAction:%@",action);
  477. if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
  478. // 应用已经解锁并且在前台
  479. if(self.uuid){
  480. [self.callProvider reportCallWithUUID:self.uuid endedAtDate:nil reason:CXCallEndedReasonDeclinedElsewhere];
  481. self.msg = nil;
  482. self.uuid = nil;
  483. }
  484. }
  485. });
  486. }
  487. -(void)provider:(CXProvider *)provider timedOutPerformingAction:(CXAction *)action{
  488. if (!self.uuid) {
  489. return;
  490. }
  491. [self.callProvider reportCallWithUUID:self.uuid endedAtDate:nil reason:CXCallEndedReasonDeclinedElsewhere];
  492. self.msg = nil;
  493. self.uuid = nil;
  494. NSLog(@"timedOutPerformingAction:%@",action);
  495. }
  496. - (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action {
  497. // 挂断电话的逻辑,如断开服务器连接等
  498. NSLog(@"performEndCallAction:%@",action);
  499. NSDate *now = [NSDate date];
  500. NSTimeInterval trt = [now timeIntervalSince1970];
  501. NSInteger time = trt*1000;
  502. NSString *strtime = [NSString stringWithFormat:@"%ld",(long)time];
  503. NSDictionary *callMsg = @{
  504. @"code":@"9",
  505. @"message": @{
  506. @"chatId":self.msg[@"fromId"],
  507. @"fromId":self.msg[@"chatId"],
  508. @"type":@"0",
  509. @"msgtype":@"close",
  510. @"timestamp":strtime,
  511. @"payload":self.msg[@"payload"]
  512. }
  513. };
  514. NSError *error;
  515. NSData *jsonData = [NSJSONSerialization dataWithJSONObject:callMsg options:0 error:&error];
  516. if (!jsonData) {
  517. NSLog(@"Got an error: %@", error);
  518. } else {
  519. NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
  520. NSLog(@"%@", jsonString); // 输出: {"name":"John","age":25}
  521. [GWebSocket.shareInstance sendMsg:jsonString];
  522. }
  523. self.uuid = nil;
  524. self.msg =nil;
  525. [action fulfill]; // 当通话结束时调用此方法完成action
  526. }
  527. -(void)reciveVoip{
  528. NSLog(@"reciveVoip-------------1");
  529. if(self.msg){
  530. NSNumber *conetType = self.msg[@"conetType"];
  531. NSLog(@"vidio:%@",self.msg[@"payload"]);
  532. BOOL audioOnly = YES;
  533. if(conetType.boolValue){
  534. audioOnly = NO;
  535. }
  536. else{
  537. audioOnly = YES;
  538. }
  539. [self startJSCall:self.msg[@"fromId"] room:self.msg[@"payload"] isCaller:NO audioOnly:audioOnly];
  540. }
  541. }
  542. //开启悬浮窗拨打方式
  543. -(void)startJSCall:(NSString *_Nonnull)chatId room:(NSString *_Nonnull)roomId isCaller:(BOOL)isCaller audioOnly:(BOOL)audioOnly{
  544. self.isJitsiMeet = YES;
  545. if(_jsyuyinctr){
  546. _jsyuyinctr.chatId = chatId.copy;
  547. _jsyuyinctr.room = roomId.copy;
  548. _jsyuyinctr.audioOnly = audioOnly;
  549. _jsyuyinctr.isCaller = isCaller;
  550. }
  551. else{
  552. UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
  553. _jsyuyinctr = [board instantiateViewControllerWithIdentifier:@"JSGController"];
  554. _jsyuyinctr.modalPresentationStyle = UIModalPresentationFullScreen;
  555. _jsyuyinctr.chatId = chatId.copy;
  556. _jsyuyinctr.room = roomId.copy;
  557. _jsyuyinctr.audioOnly = audioOnly;
  558. _jsyuyinctr.isCaller = isCaller;
  559. }
  560. NSLog(@"startJSCall roomId:%@",roomId);
  561. [_floatWindow showView:_jsyuyinctr.view];
  562. [_jsyuyinctr startJitsiMeetCall];
  563. [[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
  564. }
  565. -(void)floadinSmWindow:(NSInteger )type{
  566. if(type!=0){
  567. [_floatWindow viewInFload:type];
  568. }
  569. }
  570. +(void)closeVoip{
  571. if(app.uuid!=nil){
  572. [app.callProvider reportCallWithUUID:app.uuid endedAtDate:nil reason:CXCallEndedReasonDeclinedElsewhere];
  573. app.uuid = nil;
  574. app.msg =nil;
  575. }
  576. }
  577. +(void)JitsiMeetState:(BOOL)state{
  578. app.isJitsiMeet=state;
  579. if(!state){
  580. if(app.shouldShowLock){
  581. [app showLockScreen];
  582. }
  583. else{
  584. [app.floatWindow hide];
  585. }
  586. }
  587. }
  588. +(void)unlockAPP{
  589. app.shouldShowLock=NO;
  590. }
  591. +(void)changeFloadViewState:(BOOL)state{
  592. if (state) {
  593. [app.floatWindow hide];
  594. }
  595. else{
  596. if ([[APPLocker sharedLocker] isPasswordSet] && [[APPLocker sharedLocker] isLockEnabled]) {
  597. [app.floatWindow show:1];
  598. }
  599. }
  600. }
  601. #pragma mark 用户点击消息推送或滑动
  602. - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler {
  603. NSDictionary *userInfo = notification.request.content.userInfo;
  604. NSInteger show = [[userInfo objectForKey:@"need_present"] integerValue];
  605. if (show) {
  606. // 通知在app内也要展示
  607. completionHandler(UNNotificationPresentationOptionList | UNNotificationPresentationOptionBanner |
  608. UNNotificationPresentationOptionSound |
  609. UNNotificationPresentationOptionBadge);
  610. }
  611. }
  612. - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
  613. // 处理用户对通知的响应(点击、滑动等)
  614. if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) {
  615. // 用户点击了通知
  616. NSDictionary *userInfo = response.notification.request.content.userInfo;
  617. [self handleNotification:userInfo];
  618. NSLog(@"userInfo: %@", userInfo);
  619. } else if ([response.actionIdentifier isEqualToString:@"customActionIdentifier"]) {
  620. // 处理自定义动作(如果有的话)
  621. }
  622. completionHandler(); // 调用完成处理程序以结束操作
  623. }
  624. - (void)handleNotification:(NSDictionary *)userInfo {
  625. NSDictionary * tempDict = userInfo[@"imMsg"];
  626. NSDictionary * imMsg = tempDict[@"message"];
  627. _isNotification=true;
  628. NSMutableDictionary * mutablemsg = imMsg.mutableCopy;
  629. NSLog(@"------mutablemsg:%@",mutablemsg);
  630. NSDictionary * user = [UDManager.shareInstance getDDManager:dkuserinfo];
  631. if([user[@"id"] isEqual:imMsg[@"fromId"]]){
  632. [mutablemsg setObject:@"true" forKey:@"mine"];
  633. }else{
  634. if([Friendchat isEqual:imMsg[@"type"]]){
  635. [mutablemsg setObject:imMsg[@"fromId"] forKey:@"chatId"];
  636. }
  637. }
  638. if (imMsg) {
  639. if (![LoginStateManager sharedManager].isLoggedIn) {
  640. return;
  641. }
  642. if ([imMsg jk_hasKey:@"addFriend"]) {
  643. return;
  644. }
  645. NSString *strtype = mutablemsg[@"type"];
  646. NSInteger type = [strtype integerValue];
  647. NSString *chatId = mutablemsg[@"chatId"];
  648. NSString *titlename = mutablemsg[@"fromName"]?:@"";
  649. NSString *avatar = mutablemsg[@"fromAvatar"]?:@"";
  650. // NSLog(@"top className:%@",[[self.window jk_topMostController] class]);
  651. // NSLog(@"current className:%@",[[self.window jk_currentViewController] class]);
  652. if ([[self.window jk_currentViewController] isKindOfClass:ChatController.class]) {
  653. ChatController * currentChatVc = (ChatController *)[self.window jk_currentViewController];
  654. if (![currentChatVc.chatId isEqualToString:mutablemsg[@"chatId"]]) {
  655. currentChatVc.chatId = chatId;
  656. currentChatVc.type = type;
  657. currentChatVc.titlename = titlename;
  658. currentChatVc.avatar = avatar;
  659. [currentChatVc reloadAllData];
  660. return;
  661. }
  662. else{
  663. currentChatVc.chatId = chatId;
  664. currentChatVc.type = type;
  665. currentChatVc.titlename = titlename;
  666. currentChatVc.avatar = avatar;
  667. [currentChatVc reloadAllData];
  668. return;
  669. }
  670. }
  671. UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
  672. ChatController *chatctr = [board instantiateViewControllerWithIdentifier:@"ChatController"];
  673. UINavigationController *uiNavC = [[UINavigationController alloc] initWithRootViewController:chatctr];
  674. uiNavC.modalPresentationStyle = UIModalPresentationFullScreen;
  675. chatctr.chatId = chatId;
  676. chatctr.type = type;
  677. chatctr.titlename = titlename;
  678. chatctr.avatar = avatar;
  679. UITabBarController * tabbarVc = (UITabBarController *)self.window.rootViewController;
  680. ChatIndexController * chatListVc = tabbarVc.viewControllers[0];
  681. if (chatListVc) {
  682. [chatListVc presentViewController:uiNavC animated:YES completion:nil];
  683. }
  684. }
  685. }
  686. #pragma mark -user state and note
  687. -(void)onLoginSucc{
  688. [self initDataAfterLogin:NO];
  689. }
  690. -(void)onLogout{
  691. self.isLogin =false;
  692. [[LoginStateManager sharedManager] cleanLoginState];
  693. [self openLoginController];
  694. [self resetBadgeCount];
  695. [self resetAddFriendBadgeCount];
  696. }
  697. - (void)initDataAfterLogin:(BOOL)needRequest {
  698. self.isLogin =TRUE;
  699. [self openFMDB];
  700. [self openMainController];
  701. [self updivicetoken];
  702. [self updiviceVoIPtoken];
  703. [self sartWebsocket];
  704. if ([[APPLocker sharedLocker] isPasswordSet] && [[APPLocker sharedLocker] isLockEnabled]) {
  705. [self showLockScreen];
  706. } else{
  707. self.shouldShowLock = NO;
  708. }
  709. if (needRequest) {
  710. [[LoginStateManager sharedManager] requestUserInfoWith:^(BOOL isSuccess) {
  711. }];
  712. }
  713. }
  714. #pragma mark mainControllor Manager
  715. -(void)openMainController{
  716. NSLog(@"openMainController");
  717. UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
  718. UITabBarController *tbc = [board instantiateViewControllerWithIdentifier:@"GTabBarController"];
  719. //UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:tbc];
  720. NSArray *ctrs = tbc.viewControllers;
  721. //------------1
  722. UIViewController *time = ctrs[0];
  723. // 创建一个新的 UITabBarItem
  724. UIImage *index = [[UIImage imageNamed:@"index"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  725. UIImage *index_cur = [[UIImage imageNamed:@"index_cur"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  726. UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"TabBarItem1", @"")
  727. image:index
  728. selectedImage:index_cur];
  729. // 设置标签文本
  730. tabBarItem.title = NSLocalizedString(@"TabBarItem1", @"");
  731. // 设置标签的文本颜色
  732. [tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal];
  733. [tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateSelected];
  734. [time setTabBarItem:tabBarItem];
  735. //----------------2
  736. time = ctrs[1];
  737. // 创建一个新的 UITabBarItem
  738. UIImage *index1 = [[UIImage imageNamed:@"txl"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  739. UIImage *index_cur1 = [[UIImage imageNamed:@"txl_cur"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  740. UITabBarItem *tabBarItem1 = [[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"TabBarItem2", @"")
  741. image:index1
  742. selectedImage:index_cur1];
  743. // 设置标签文本
  744. tabBarItem1.title = NSLocalizedString(@"TabBarItem2", @"");
  745. // 设置标签的文本颜色
  746. [tabBarItem1 setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal];
  747. [tabBarItem1 setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateSelected];
  748. [time setTabBarItem:tabBarItem1];
  749. //------------------3
  750. time = ctrs[2];
  751. // 创建一个新的 UITabBarItem
  752. UIImage *index2 = [[UIImage imageNamed:@"qunzu"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  753. UIImage *index_cur2 = [[UIImage imageNamed:@"qunzu_cur"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  754. UITabBarItem *tabBarItem2 = [[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"TabBarItem3", @"")
  755. image:index2
  756. selectedImage:index_cur2];
  757. // 设置标签文本
  758. tabBarItem2.title = NSLocalizedString(@"TabBarItem3", @"");
  759. // 设置标签的文本颜色
  760. [tabBarItem2 setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal];
  761. [tabBarItem2 setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateSelected];
  762. [time setTabBarItem:tabBarItem2];
  763. //------------------4
  764. time = ctrs[3];
  765. // 创建一个新的 UITabBarItem
  766. UIImage *index3 = [[UIImage imageNamed:@"wode"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  767. UIImage *index_cur3 = [[UIImage imageNamed:@"wode_cur"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  768. UITabBarItem *tabBarItem3 = [[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"TabBarItem4", @"")
  769. image:index3
  770. selectedImage:index_cur3];
  771. // 设置标签文本
  772. tabBarItem3.title = NSLocalizedString(@"TabBarItem4", @"");
  773. // 设置标签的文本颜色
  774. [tabBarItem3 setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateNormal];
  775. [tabBarItem3 setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateSelected];
  776. [time setTabBarItem:tabBarItem3];
  777. self.window.rootViewController = tbc;
  778. }
  779. -(void)openLoginController{
  780. UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
  781. GLoginController *login = [board instantiateViewControllerWithIdentifier:@"LoginController"];
  782. UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:login];
  783. self.window.rootViewController = nav;
  784. }
  785. #pragma mark openSocket
  786. -(void)sartWebsocket{
  787. [[GWebSocket shareInstance] connectWebSocket];
  788. }
  789. #pragma mark init DB
  790. -(void)openFMDB {
  791. [[GDBManager shareInstance] initDataBase];
  792. }
  793. #pragma mark - UISceneSession lifecycle
  794. //- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
  795. // // Called when a new scene session is being created.
  796. // // Use this method to select a configuration to create the new scene with.
  797. // return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
  798. //}
  799. //
  800. //
  801. //- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
  802. // // Called when the user discards a scene session.
  803. // // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
  804. // // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
  805. //}
  806. #pragma mark - Core Data stack
  807. @synthesize persistentContainer = _persistentContainer;
  808. - (NSPersistentContainer *)persistentContainer {
  809. // The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
  810. @synchronized (self) {
  811. if (_persistentContainer == nil) {
  812. _persistentContainer = [[NSPersistentContainer alloc] initWithName:@"555IM"];
  813. [_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
  814. if (error != nil) {
  815. // Replace this implementation with code to handle the error appropriately.
  816. // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
  817. /*
  818. Typical reasons for an error here include:
  819. * The parent directory does not exist, cannot be created, or disallows writing.
  820. * The persistent store is not accessible, due to permissions or data protection when the device is locked.
  821. * The device is out of space.
  822. * The store could not be migrated to the current model version.
  823. Check the error message to determine what the actual problem was.
  824. */
  825. NSLog(@"Unresolved error %@, %@", error, error.userInfo);
  826. abort();
  827. }
  828. }];
  829. }
  830. }
  831. return _persistentContainer;
  832. }
  833. #pragma mark - Core Data Saving support
  834. - (void)saveContext {
  835. NSManagedObjectContext *context = self.persistentContainer.viewContext;
  836. NSError *error = nil;
  837. if ([context hasChanges] && ![context save:&error]) {
  838. // Replace this implementation with code to handle the error appropriately.
  839. // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
  840. NSLog(@"Unresolved error %@, %@", error, error.userInfo);
  841. abort();
  842. }
  843. }
  844. #pragma mark applock
  845. - (void)showLockScreen {
  846. // 确保在主线程执行
  847. if (self.shouldShowLock && [[APPLocker sharedLocker] isPasswordSet] && [[APPLocker sharedLocker] isLockEnabled]) {
  848. NSLog(@"showLockScreen--------------1");
  849. if (self.isJitsiMeet) {
  850. [_floatWindow viewInFload:0];
  851. return;
  852. }
  853. else{
  854. [_floatWindow show:1];
  855. }
  856. return;
  857. }
  858. if (!self.isJitsiMeet) {
  859. [_floatWindow hide];
  860. }
  861. }
  862. - (void)applicationWillTerminate:(UIApplication *)application {
  863. [[OSSManager sharedManager] applicationWillTerminate];
  864. }
  865. @end