Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(package_info_plus): add install time #3434

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Andrew-Bekhiet
Copy link

Description

Adds package install time to iOS and Android

  • On Android: uses PackageManager.firstInstallTime
  • On iOS: gets the creation date of the app's documents directory
    • The documents directory should be created automatically when the app is installed, based on this SO answer

Related Issues

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

@miquelbeltran
Copy link
Member

Thanks! I took a quick look and looks promising, thanks for taking the time implementing tests as well.

Some ideas to extend this:

  • Supporting web and Linux: This could be done looking at the creation or modification date of the version.json file, although this may depend on how the file was copied/if the OS preserved the creation/mod date, etc. but could give a rough idea.
  • Supporting MacOS: Should be the same as with iOS?
  • Supporting Windows: Similar to the web/linux implementation, but with the app .exe (this is how it reads the version atm)

@Andrew-Bekhiet
Copy link
Author

  • Linux: Dart doesn't provide an API for checking file creation date, so I guess I'll use stat command or something similar
  • Web: I'm not sure how would that work, as version.json would be the same for all users, right?
  • MacOS: Yeah we can do the same as iOS. I'm not very experienced with Apple ecosystem, but how about the creation date of the app bundle? Would that work? I'm going to try it anyways
  • Windows: I think there is a method that checks the windows registry, if that fails we can check the creation date of the app exe file

At first I didn't want to implement this for desktop OSes because the user could easily change files attributes and mess with this, so this shouldn't be used for anything critical like determining a free trial period or anything similar

In these cases developers are encouraged to implement this feature in their apps as it fits their needs

@miquelbeltran
Copy link
Member

thanks for the recent pushes! let me know when it's ready for review

@Andrew-Bekhiet
Copy link
Author

I think it is ready, here is a summary of what I decided to do when implementing this for desktop:

  • Windows: check the creation date of the app executable, return last modified date if creation date is unavailable as some filesystems don't track creation date
  • Linux: get the creation time (birth) of the app executable or fallback to modification date as some old linux kernels don't keep track of creation date
  • MacOS: same implementation as iOS, checks the creation date of the app's NSDocuments directory

I have no idea how can this be implemented on web using only version.json because the version.json file will be the same for all users of the app, and I can't think of a way to get any metadata about it

However, It can be implemented by storing the first launch time in local storage or something similar, but I think this should be left out for the developers to choose how they want to implement it

What do you think about this? Do you have any suggestions?

@miquelbeltran
Copy link
Member

That's fine! Thanks for implementing the other platforms as well. Perhaps install time on web doesn't make much sense, as opposed to the other platforms, the user never installs anything, so it's fair to say this feature is not supported on web.

@Andrew-Bekhiet
Copy link
Author

Ok great!
Do I need to do anything else before you review it? I think that last CI check failed due to a timeout in the android emulator, but it succeeded on earlier commits

@miquelbeltran
Copy link
Member

The emulator job is very unstable so it's not mandatory to pass the review. I just need time to look at this (it may take a while)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants