2017-01-11 40 views
0

我正在使用iOS版本9和swift。我可以在应用程序处于活动状态时接听电话,但当应用程序关闭或在后台时,我遇到问题,它只收到通知,而不是完整的铃声(我正在使用SinchService),但它不起作用。我已经添加了VoIP的证书,它是有效的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 
} 

回答

0

在你localnotification方法,你不设置任何声音。给声明添加声音