ios - Push notification not recieved on first launch -


i using sinch sdk on project. push notification type voip not recieved on first launchs, recieved after many kill/open application. initialisation of 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) data!)     }     return sinchclient } 

this when set token

func pushregistry(registry: pkpushregistry!, didupdatepushcredentials credentials: pkpushcredentials!, fortype type: string!) {     // register voip push token (a property of pkpushcredentials) server      if let sinchclient = sinchmanager.sharedinstance.sinchclient{         if let _ = sessionmanager.sharedinstance.user {             sinchclient.registerpushnotificationdata(credentials.token)          }      }  } 

how can resolve this

i solved problem moving registration of voip push

let mainqueue = dispatch_get_main_queue()     // create push registry object     let voipregistry: pkpushregistry = pkpushregistry(queue: mainqueue)     // set registry's delegate self     voipregistry.delegate = self     // set push type voip     voipregistry.desiredpushtypes = [pkpushtypevoip] 

before initializing push object instantiation , configuration

 self.push = sinch.managedpushwithapsenvironment(.production)     self.push!.delegate = self     self.push!.setdesiredpushtype(sinpushtypevoip)     self.push!.registerusernotificationsettings() 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -