Cwa-app-ios: Question reg. #2132 („Days since installation“)

Created on 12 Mar 2021  ·  6Comments  ·  Source: corona-warn-app/cwa-app-ios

Avoid duplicates

  • [X] Question is not already answered in the FAQ
  • [X] Question has not already been asked in another issue

Your Question

  • PR: #2132
  • Question:
    What will users who update the app see for a number?
    The days that passed since the update or the actual time how long they have the app installed?
question

Most helpful comment

@Ein-Tim

From the code in the PR you can see that the installation date is inferred from the creation time of the app's folders. Upgrading the app does not affect this parameter.

enum InstallationDate {

    static func inferredFromDocumentDirectoryCreationDate() -> Date {
        guard
            let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last,
            let attributes = try? FileManager.default.attributesOfItem(atPath: documentsURL.path)
        else {
            return Date()
        }
        return attributes[.creationDate] as? Date ?? Date()
    }
}

For Android, there is an API call that returns the first install date. Here the OS keeps track of the installation time.


Corona-Warn-App Open Source Team

All 6 comments

@Ein-Tim Since installation. Updates should not reset the count.

@dsarkar

Thanks!

So even when I update from version 1.14.4 (which doesn't show how long the app was installed) to version 1.15, the correct days will be shown?

@Ein-Tim very good question! 👍

I guess the answer depends on how they designed their solution.
And asking this question before the release of such a feature gives the devs the chance to design it from the beginning in a way that meets user expectations; instead of getting many questions and confused users after a release.

@ndegendogo

Yes, I wanted to ask this before the release.
If the app will show 0 days since installation after update to 1.15 then this needs a in app explanation (Pop-Up, etc.).

@Ein-Tim

From the code in the PR you can see that the installation date is inferred from the creation time of the app's folders. Upgrading the app does not affect this parameter.

enum InstallationDate {

    static func inferredFromDocumentDirectoryCreationDate() -> Date {
        guard
            let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last,
            let attributes = try? FileManager.default.attributesOfItem(atPath: documentsURL.path)
        else {
            return Date()
        }
        return attributes[.creationDate] as? Date ?? Date()
    }
}

For Android, there is an API call that returns the first install date. Here the OS keeps track of the installation time.


Corona-Warn-App Open Source Team

Thanks @heinezen!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chk-code picture chk-code  ·  102Comments

Tho-Mat picture Tho-Mat  ·  65Comments

inforsgit picture inforsgit  ·  97Comments

MichaelElbflorenz picture MichaelElbflorenz  ·  53Comments

svesch2006 picture svesch2006  ·  39Comments