Trigger event on first launch in xcode

Open AppDelegate.swift and modify this line:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
    return true
}
to
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {

 if (NSUserDefaults.standardUserDefaults().boolForKey("HasLaunchedOnce")){
  //app already launched 
  println("app already launched") 
 }else{
  NSUserDefaults.standardUserDefaults().setBool(true, forKey: "HasLaunchedOnce")
  NSUserDefaults.standardUserDefaults().synchronize()
  //This is the first launch ever
 
  println("this is the first launch ever")
 }

 return true
}

0 تعليقات

إرسال تعليق

Post a Comment (0)

أحدث أقدم
NERV Open Source

Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.

Explore NERV on GitHub →