基于Linphone SDK的iOS推送通知配置及回调问题咨询
Linphone iOS 推送通知配置问题解答
问题1:设置mCore.pushNotificationsEnabled = true后,是否无需自定义PushRegistry?还需补充配置吗?
- 设置
mCore.pushNotificationsEnabled = true后,Linphone SDK会自动处理PushKit的注册流程,不需要手动编写自定义PushRegistry。 - 必须补充的配置:
- 在Xcode项目的Capabilities中开启Push Notifications和Voice over IP权限;
- 确保Apple开发者账号已配置有效的VoIP推送证书;
- 实现
CoreDelegate协议,用于接收推送相关回调; - Core初始化完成后,调用
core.setPushNotificationToken(_:type:)方法传入设备的VoIP推送token,token类型指定为.VoIP。
问题2:找不到onPushNotificationReceived(core: Core, payload: String)回调函数,也不知道怎么调用?
这个方法是CoreDelegate协议中的回调,需要按以下步骤配置才能使用:
- 让你的类(如Core管理类或AppDelegate)遵循
CoreDelegate协议:class CoreManager: CoreDelegate { // 类内部逻辑 } - 初始化Core时,将当前类设置为Core的代理:
core.addDelegate(self) - 实现回调方法:
func onPushNotificationReceived(core: Core, payload: String) { // 处理来电唤醒、UI展示等逻辑 } - 系统收到VoIP推送时,在PushKit的
didReceiveIncomingPushWith回调中,将推送payload转为字符串,调用core.processPushNotification(payload:),SDK会自动触发onPushNotificationReceived回调。
问题3:如果无法自定义PushRegistry,onPushNotificationReceived所需的payload包含哪些内容?需要附带注册数据吗?
- 必备的payload内容(Linphone标准格式):
call_id:来电的唯一标识;from:来电方的SIP地址;to:接收方的SIP地址;pn_type:固定为voip,标识推送类型;- 可选字段:
pn_version、sound等。
- 不需要附带设备注册数据(如推送token),Linphone服务器在你注册token时已关联用户信息,推送时会直接发送符合格式的payload到目标设备。
内容的提问来源于stack exchange,提问作者steind.VY
相关产品推荐
相关产品推荐

