Notice: You're viewing an old version of the Nylo documentation.
Consider upgrading your project to Nylo 6.x.
Advanced

App Usage



Introduction

Nylo allows you to monitor your app usage out of the box but first you need to enable the feature in one of your app providers.

Currently, Nylo can monitor the following:

  • App launches
  • First launch date

After reading this documentation, you will learn how to monitor your app usage.


Setup

Open your app/providers/app_provider.dart file.

Then, add the following code to your boot method.

class AppProvider implements NyProvider {
  @override
  boot(Nylo nylo) async {
    ...

    nylo.monitorAppUsage(); // Add this line to monitor app usage

This will enable app usage monitoring in your app. If you ever need to check if app usage monitoring is enabled, you can use the Nylo.instance.shouldMonitorAppUsage() method.


Monitoring App Launches

You can monitor the number of times your app has been launched using the Nylo.appLaunchCount method.

App launches are counted each time the app is opened from a closed state.

A simple example of how to use this method:

int? launchCount = await Nylo.appLaunchCount();

print('App has been launched $launchCount times');


Monitoring App First Launch Date

You can monitor the date your app was first launched using the Nylo.appFirstLaunchDate method.

Here's an example of how to use this method:

DateTime? firstLaunchDate = await  Nylo.appFirstLaunchDate();

print("App was first launched on $firstLaunchDate");


Monitoring App Total Days Since First Launch

You can monitor the total days since your app was first launched using the Nylo.appTotalDaysSinceFirstLaunch method.

Here's an example of how to use this method:

int totalDaysSinceFirstLaunch = await Nylo.appTotalDaysSinceFirstLaunch();

print("It's been $totalDaysSinceFirstLaunch days since the app was first launched");