2016-11-10 4 views
1

프로젝트에서 sinch SDK를 사용하고 있습니다. voip 유형의 푸시 알림은 처음 실행될 때 수신되지 않지만 많은 종료/실행 응용 프로그램 후에 수신됩니다. 이 내가 당신을, 활성 aactive 연결을 시작 해달라고 바로 밀어 싶다면이최초 출시시 푸시 알림 수신되지 않음

답변

2

를 사용해야 난 당신과 같은 코드를 수정

self.push = Sinch.managedPushWithAPSEnvironment(.Production) 
    self.push!.delegate = self 
    self.push!.setDesiredPushType(SINPushTypeVoIP) 
    self.push!.registerUserNotificationSettings() 
0

를 해결할 수있는 방법을 토큰

func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!) { 
    // Register VoIP push token (a property of PKPushCredentials) with server 

    if let sinchCLient = SinchManager.sharedInstance.sinchClient{ 
     if let _ = SessionManager.sharedInstance.user { 
      sinchCLient.registerPushNotificationData(credentials.token) 

     } 

    } 

} 

을 설정할 때 이것은 클라이언트

func initSinchClient(userIdentifier : String!) -> SINClient! { 


    if let _ = self.sinchClient{ 
     self.sinchClient?.unregisterPushNotificationDeviceToken() 
     self.sinchClient?.stopListeningOnActiveConnection() 
     self.sinchClient?.terminate() 
    } 

    self.sinchClient = Sinch.client(withApplicationKey: SinchConstants.SinchAppKey, applicationSecret: SinchConstants.SinchApplicationSecret, environmentHost: SinchConstants.SinchEnvironmentHost, userId: userIdentifier) 
    self.sinchClient!.delegate = self 
    self.sinchClient!.call().delegate = self 

    self.sinchClient!.setSupportActiveConnectionInBackground(true) 
    self.sinchClient!.setSupportPushNotifications(true) 
    self.sinchClient!.setSupportCalling(true) 
    self.sinchClient?.enableManagedPushNotifications() 
    self.sinchClient!.start() 
    self.sinchClient!.startListeningOnActiveConnection() 

    if let pushTokenData = UserDefaults.standard.object(forKey: "PushNotificationToken"){ 
     self.sinchClient!.registerPushNotificationData((pushTokenData as! NSData) as Data!) 
    } 
    return sinchClient 
} 

의 초기화이다 연결이 소켓을 설정하고 응용 프로그램이 오래있을 때 바로 전화가 오게됩니다.

왜 init에서이 작업을 수행하는지 묻습니다. 당신은 그렇게해서는 안됩니다. 로그인 로그 아웃 기능이 있다면 init 명령이 아닌 duriong 로그 아웃을 수행해야합니다. 당신이 terminateSuccesfully

if let _ = self.sinchClient{ 
    self.sinchClient?.unregisterPushNotificationDeviceToken() 
    self.sinchClient?.stopListeningOnActiveConnection() 
    self.sinchClient?.terminate() 
} 
+0

푸시 객체 인스턴스화 및 구성을 초기화하기 전에 VOIP 푸시

let mainQueue = dispatch_get_main_queue() // Create a push registry object let voipRegistry: PKPushRegistry = PKPushRegistry(queue: mainQueue) // Set the registry's delegate to self voipRegistry.delegate = self // Set the push type to VoIP voipRegistry.desiredPushTypes = [PKPushTypeVoIP] 

의 등록을 이동하여 문제를 해결 권하다. 문제는 해결되지 않습니다. 푸시 알림은 응용 프로그램을 종료하고 다시 열 때까지 수신되지 않습니다. –