Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if it's your first run?

Tags:

ios

xamarin

I wonder how I can check whether it's the first run of my ios app, in order to start with a specific view. I saw many ways to do with Objective-C, but not how to implement it in Xamarin.

like image 357
vlady Avatar asked Oct 07 '13 20:10

vlady


People also ask

How long should be your first run?

“An ideal, and not too overwhelming, duration for a first run is about 30 minutes in total,” explains Sascha. “This also includes the time necessary for a proper warm up.” This ensures your muscles are ready for the run session. “Make sure you run slowly – too slow rather than too fast,” ensures the expert.

What is considered a beginner runner?

That kind of stress on the body is earned. To start with, a beginner needs at least two days, no more than three. A beginner can only start to think of themselves as becoming an intermediate runner after around six months of consistent training — sometimes even longer.

Is first run the hardest?

"The first mile is the hardest because it leads to a rapid increase in oxygen demand to your entire body," says Sadi Raza, MD, FACC, a board-certified cardiologist in Dallas, Texas.


1 Answers

I'm not familiar with Xamarin, but this sounds as easy as checking the existence of a custom entry, say LaunchedBefore, in NSUserDefaults at the app launch and writing it if not found.

Something like

public override void FinishedLaunching (UIApplication application) {
    var defaults = NSUserDefaults.StandardUserDefaults;
    const string key = "LaunchedBeforeKey";
    if (!defaults.BoolForKey(key)) {
        // First launch
        user.SetBool(true, key);
        defaults.Synchronize();

        // Do stuff specific to the first launch here...
    }

    //...
}

I'm using "LaunchedBefore" as opposed to "FirstLaunch" since BoolForKey() will return false in case the key doesn't exist, so it's semantically better this way.

like image 180
Gabriele Petronella Avatar answered Oct 08 '22 17:10

Gabriele Petronella