Search code examples
swiftxcodemessageuialertview

How to display a message on startup about new feature only to pervious users


I am adding new features and want to create a message (like a UIAlertController) at app startup that explains the new features.

Is there anyway to do this to users that have already downloaded the app? New users that download the app don't need to see the new features message because to them every feature is new since they've never used the app before. Or perhaps I would have a message but the content would be different.

Thanks!


Solution

  • The easiest way is to save the current version in UserDefaults:

    var defaults = UserDefaults.standard
    defaults.set(2.2, forKey: "lastVersion")
    

    Then on your Initial View Controller check to see if they have the latest version:

    override func viewDidLoad() {
         super.viewDidLoad()
         if let lastVersion = NSUserDefaults.standard(forKey: "lastVersion") {
            print(lastVersion)
         }
    }
    

    Then it's up to you on how you wish to present the list of new features.