美文网首页
iPad 利用SIP协议拨打电话

iPad 利用SIP协议拨打电话

作者: iOS小武哥 | 来源:发表于2019-10-29 14:39 被阅读0次

    一、前言:

    iPad 有可以插卡的,有的不可以插卡,插卡的可以正常拨打电话,不插卡的就不能拨打电话,但是可以通过网络SIP协议进行拨打电话,这个需要你有一台服务器,我们公司是用别人家的一个平台,但是想把这个打电话的功能移植到iPad上面!这里只是简单的实现拨打电话,挂断电话,监听拨打电话状态基本功能!

    二、简介:

    • linphone是开源SIP电话,可在移动和桌面环境(iOS,Android,MAC OSX)和Web浏览器上等使用。
    • linphone是核心引擎:这是一个实现Linphone所有功能的库。Liblinphone是一个功能强大的SIP VoIP视频SDK,任何人都可以用来向应用程序添加音频或视频通话功能。它提供了一个高级api来发起,接收,终止音频和视频呼叫。
    • linphone及其所有依赖项均使用纯C编写。
    • linphone点击这里下载

    三、集成:

    可以下载SDK手动导入项目中!
    或使用Cocoapods导入使用如下:
    source 'https://gitlab.linphone.org/BC/public/podspec.git'
    platform :ios,  '9.0'
    target 'xxxxx' do
    pod 'linphone-sdk','4.2'
    end
    

    四、代码实现:

    用的是这个作者,他在linphone的基础上封装了一层,更容易使用,点击下载文件,下载完成将EasySip放在项目中去!

    五、使用:

    • 注册:(其实这个部分可以给后台来做,前端就打电话就行)
    //1.注册
    [[ESSipManager instance] login:@"用户名" password:@"密码" displayName:@"" domain:@"IP地址+端口号" port:@"端口号" withTransport:@"UDP"];
    
    • 登录:这个登录是走后台接口,为了是绑定设备!

    • 拨打电话:

    [[ESSipManager instance] call:@"电话号码" displayName:@""];
    
    • 挂断电话:
    [[ESSipManager instance] hangUpCall];
    
    • 监听电话的状态
    //可以在VC中添加观察者,就可以监听到电话状态
    NSString *const ES_ON_REMOTE_OPEN_CEMERA = @"ES_ON_REMOTE_OPEN_CEMERA";
    NSString *const ES_ON_CALL_COMMING = @"ES_ON_CALL_COMMING";
    NSString *const ES_ON_CALL_END = @"ES_ON_CALL_END";
    NSString *const ES_ON_CALL_STREAM_UPDATE = @"ES_ON_CALL_STREAM_UPDATE";
    

    六、结语:

    到这里我们就完成了电话的拨打,挂断以及监听电话状态!之前做的时候发现打电话的时候提示:外地号码前 +0 这个Bug,经研究是注册没有成功,后台没有拿到注册的IP地址,所有回出现这种情况,安卓那边会出现:电话号码前+86的情况解决是在电话前面拼接IP地址core.interpretUrl用到了这个方法!

    七、悲剧(被拒)

    Guideline 5.0 - Legal
    
    
    Recently, the Chinese Ministry of Industry and Information Technology (MIIT) requested that CallKit functionality be deactivated in all apps available on the China App Store.
    
    During our review, we found that your app currently includes CallKit functionality and has China listed as an available territory in App Store Connect.
    
    Next Steps
    
    This app cannot be approved with CallKit functionality active in China. Please make the appropriate changes and resubmit this app for review.
    
    If you have already ensured that CallKit functionality is not active in China, you may reply to this message in Resolution Center to confirm. 
    
    Voice over Internet Protocol (VoIP) call functionality continues to be allowed but can no longer take advantage of CallKit’s intuitive look and feel. CallKit can continue to be used in apps outside of China.
    
    我的天那,被拒了,意思是在中国区域内,不能使用CallKit框架,在EasySip中用到CallKit的文件全部删掉,或者是注释掉,在打包上传即可!

    相关文章

      网友评论

          本文标题:iPad 利用SIP协议拨打电话

          本文链接:https://www.haomeiwen.com/subject/dtawvctx.html