4

I have been successful with creating quickblox session and it works when moving from one page to another. But once the web app gets refreshed, the session gets lost and i have to initialize again using authentication key etc.

I tried persisting the token i got when session got created and initializing the quickblox object using this token but it gives an error saying i need to provide authentication key etc. Which according to their documentation should have worked.

I was wondering if there is a more efficient way of managing the session? I don't like having to re-initialize the session everytime the app gets refreshed. Any pointers would be appreciated. I usually persist session detail in local storage using pouch db. The app is an angular js app, using ui-router. I use the stateprovider's run function to initialize the qb object, but I first check if there is an existing session.

LcDb.get session().then(
  function(res){
     Qb.init(res.token);
  },
  function(err){ 
     Var config = {
              on: {
                sessionExpired:function(next,retry){

                 }
                }
             QB.init(app.Id,app.key,app.secret,config);
              })
        QB.create session(function(err,result){

1 Answers1

0

I got the same problem in my project, what I do is, that first of all, I check QB.chat is existed or not, If QB.chat does not exist then, You must have to reinitialize all the stuff, like (create session, login, connect, setup all handler) using your login credentials (username and password).
I have implemented in angular js so, I added this code into app.js into run function, this call every time when state change.
You must have to implement in a way that QB.chat is checking whenever you refreshing page.

Hope this will help you.

Mayur Shah
  • 3,344
  • 1
  • 22
  • 41