How to check first run app with ionic app?

Hello please help me I want to check first run app on ionic application? Thanks

Hello, well the dumb idea I would suggest, is to record this in a IonViewDidLoad event like this.

  ionViewDidLoad() {
    console.log('ionViewDidLoad HomePage');

But your question probably assume you want to write this into a log file. Easy then, use ionic push function to pile in every file you see fit.

If you want to check if it’s the very first time the app is run on a device, I would suggest to use the Storage for this purpose.

If something was stored => It’s not the first time
If storage is empty => Most probably the first time

It isn’t 100% accurate but might be enough for your purpose


Something like:

import { Storage } from '@ionic/storage';

export class MyApp {
  constructor(private storage: Storage) { }

 storage.get('first_time').then((val) => {
     if (val !== null) {
        console.log('app isn't for the first time started');
     } else {
        console.log('probably the first time');
           storage.set('first_time', 'done');

P.S.: Code need to be enhanced, you should access the storage only when app and storage are ready


Thank you very much. Your answer is good

1 Like

But how do you handle the case when local storage is cleaning up because of low disk space on ios?

1 Like

Ionic storage doesn’t use local storage it uses sqlite storage which is persistent. And won’t be cleaned by OS