I am using the sinch SDK on a project. The push notification with type voip are not recieved on the first launchs, but recieved after many kill/open application. this is the initialisation of the client
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
}
This is when i set the token
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)
}
}
}
how can i resolve this
i solved the problem by moving the registration of VOIP push
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]
before initializing the push object instantiation and configuration
self.push = Sinch.managedPushWithAPSEnvironment(.Production)
self.push!.delegate = self
self.push!.setDesiredPushType(SINPushTypeVoIP)
self.push!.registerUserNotificationSettings()