How to check if someone is logged in every day?

Hi all,

Is this possible? I want to check if someone is logged in today…

I also want to check if the same perso nis logged in tomorrow in the app as well…

How could we achieve this?

why do you need that? daily bonus or sth. else?

Something like that, yes.

I do not know how to do it with Ionic, though. Could somebody help me out?

pseudo code:

onAppStartOrResume () {
 var days_online = /* Get the Array from any possible Storage*/;
 if( typeof(days_online) === "undefined" || days_online == null) days_online = [];

 if(days_online.indexOf( /*Date of today */) == -1){
  days_online.push(/* Date of today */);
  // save days_online again.
 }
}

Try sth. like this, but keep in mind that when you want it more secure or you give them good bonuses you might want to count it on a server instead of localy like my pseudocode.

1 Like

Thanks @user5555. I appreciate it!

your welcome
By the way, when you could explain me a little more what system your are going to build, then I could help you even more…
Just ask if you need more glues on how to do it. :wink:

Hi @user5555: it’s a social media platform for employees. Nothing special really, but I just needed an incentive for people to use it.

Ok that seems pretty straightforward.

Do you use dailystreaks or just how many days the user has used the app in general?
You should do it on the server when it has an inpact, and the employer want to know who is using it…

Dailystreaks would be the best, I guess.

Yes, exactly. I’ll check what I can do. Appreciate the help, thank you user!

With daily streak you could use a second if block

onAppStartOrResume () {
 var days_online = /* Get the Array from any possible Storage*/;
 if( typeof(days_online) === "undefined" || days_online == null) days_online = [];

 if(days_online.indexOf( /*Date of today */) == -1){

  if(days_online.indexOf( /* last day they had to login(minus weekend) */) == -1) days_online = [];// reset it

  days_online.push(/* Date of today */);
  // save days_online again.
 }
}

That way you could simply do days_online.length to get the current streak and keep the array clean at the same time.

1 Like

Wish the Ionic community had more people like you. Thanks @user5555, I really appreciate it!

1 Like