// // HDLLinPhoneSDK.m // HDLLinPhoneSDK // // Created by 陈启扬 on 2021/8/3. // Copyright © 2021 陈启扬. All rights reserved. // #import "HDLLinPhoneSDK.h" #import "HDLLinphoneManager.h" #import "HDLLinphoneIntercomVC.h" #import "HDLLinPhoneCommon.h" #import "HDLLPOnMonitorViewController.h" @implementation HDLLinPhoneSDK + (instancetype)instance{ static HDLLinPhoneSDK *service = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ service = [[HDLLinPhoneSDK alloc] init]; [NSNotificationCenter.defaultCenter addObserver:service selector:@selector(registrationUpdate:) name:@"LinphoneRegistrationUpdate" object:nil]; }); return service; } -(void)dealloc{ // [NSNotificationCenter.defaultCenter remo]; } -(void)login:(NSString*)username password:(NSString*)pwd domain:(NSString*) domain{ [HDLLinphoneManager.instance login:username password:pwd domain:domain]; } - (void)registrationUpdate:(NSNotification *)notif { LinphoneRegistrationState state = [[notif.userInfo objectForKey:@"state"] intValue]; if (state == LinphoneRegistrationFailed){ } else if (state == LinphoneRegistrationOk) { // HDLLinphoneIntercomVC *vc=[[HDLLinphoneIntercomVC alloc]init]; // [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{ // // }]; NSLog(@"登录成功啦"); }else if (state==10){//接收到呼叫通知 self.IsAutoJumpCallView=YES; if(self.IsAutoJumpCallView){ NSString *callId=[NSString stringWithFormat:@"%@",[notif.userInfo objectForKey:@"callID"]]; BOOL hasVideo=(BOOL)[notif.userInfo objectForKey:@"hasVideo"]; HDLLinphoneIntercomVC *vc=[[HDLLinphoneIntercomVC alloc]init]; vc.CallId=callId; vc.hasVideo=hasVideo; vc.hdlLinphoneCallDelegate=self.hdlLinphoneCallDelegate; [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{ }]; } } } -(void)initalLinPhone{ [HDLLinphoneManager.instance initalLinPhonal]; } -(void)callWithUserName:(NSString*)username title:(NSString *)title{ HDLLPOnMonitorViewController *vc=[[HDLLPOnMonitorViewController alloc]init]; // vc.CallId=callId; // vc.hasVideo=YES; vc.hdlLinphoneCallDelegate=self.hdlLinphoneCallDelegate; vc.modalPresentationStyle = UIModalPresentationFullScreen; vc.userName=username; vc.titleName=title; [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{ }]; } /** * 跳转呼叫页面 * * @param titleName 标题 */ -(void)gotoHDLLinphoneIntercomVC:(NSString*)titleName{ // NSString *callId=[NSString stringWithFormat:@"%@",[notif.userInfo objectForKey:@"callID"]]; // BOOL hasVideo=(BOOL)[notif.userInfo objectForKey:@"hasVideo"]; HDLLinphoneIntercomVC *vc=[[HDLLinphoneIntercomVC alloc]init]; // vc.CallId=callId; vc.hasVideo=YES; vc.hdlLinphoneCallDelegate=self.hdlLinphoneCallDelegate; vc.titleName=titleName; vc.modalPresentationStyle = UIModalPresentationFullScreen; [[HDLLinPhoneCommon topMostController] presentViewController:vc animated:YES completion:^{ }]; } -(void)logoutAllLinphoneUser{ } -(void)clearAllConfigs{ } @end