AppDelegate.m 40 KB

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