VoIP铃声无法正常工作

时间:2017-01-11 12:59:05

标签: ios swift notifications sinch

我使用的是iOS 9和swift。我可以在应用程序处于活动状态时接听电话,但是当应用程序关闭或在后台时,我有一个问题,它只会收到通知,而不是完整的铃声(我使用的是SinchService)但它是&#39 ; s不工作。我已经添加了VoIP证书并且它是有效的

代码

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    sinch?.push().application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
    sinch?.push().application(application, didReceiveRemoteNotification: userInfo)
}


func startManager() {
    let config = SinchService.config(withApplicationKey: VoiceManager.SinchKey, applicationSecret: VoiceManager.SinchSecret, environmentHost: VoiceManager.SinchHost).pushNotifications(with: SINAPSEnvironment.development)
    let sinch = SinchService.service(with: config)
    sinch?.delegate = self
    sinch?.callClient().delegate = self

    let push = Sinch.managedPush(with: SINAPSEnvironment.development)
    push?.delegate = self
    push?.setDesiredPushTypeAutomatically()

    let appDelegate: AppDelegate = (UIApplication.shared.delegate as! AppDelegate)
    appDelegate.sinch = sinch
    appDelegate.push = push
}

// MARK: - SINCallClientDelegate

func client(_ client: SINCallClient!, didReceiveIncomingCall call: SINCall!) {
    //show calling view
    let controller = UIViewController.currentViewController()
    VoiceCallingViewController.show(call: call, viewController: controller)
}


func client(_ client: SINCallClient!, localNotificationForIncomingCall call: SINCall!) -> SINLocalNotification! {
    let notification = SINLocalNotification()
    notification.alertAction! = LanguageManager.localizedString(key: "answer")
    notification.alertBody = "\(LanguageManager.localizedString(key: "incomming-call")) \(call.remoteUserId)"
    return notification
}

1 个答案:

答案 0 :(得分:0)

您没有在本地通知方法中设置任何声音。为通知添加声音