0

I want the users to try certain features in a specific limited of time, say 2 weeks after installing (and after that they can buy it).

So my naive idea is, say, to use sharedPreference to store the first launch time, and then keep checking this date with the System time.

However, the user can simply change the system time of the android phone, and use this "limited feature" indefinitely. My app should also be able to work offline so checking with the internet time seems not a good idea.

Is there any good framework how this kind of coding can be done?

Ivan
  • 149
  • 1
  • 12
  • Write it to File on device? assuming user don't know how to delete the file from phone. – kosa Sep 19 '14 at 17:51
  • I think the main crack to this feature is changing system time of the phone...way easier than accessing the file with the first launch time – Ivan Sep 19 '14 at 17:56

3 Answers3

2

You must use a remote server and database. The system clock isn't the only tweak, the user can simply clear the data associated with the app.

You need the unique ID of the device. At first usage of app, you register this in a remote database with a timestamp on it. You need only to check the server whenever this feature is triggered.

Community
  • 1
  • 1
Olayinka
  • 2,813
  • 2
  • 25
  • 43
  • How about checking against a fixed date? So I don't need to invoke the sharedPreference... But then internet is still required to check against a time – Ivan Sep 19 '14 at 17:47
  • remote database definitely is a valid solution... if I can handle a remote server. But I don't have one... and I don't want to store user info to avoid privacy concerns... – Ivan Sep 19 '14 at 17:51
  • @Ivan you don't have a choice here. if users will pay for that feature then they wouldn't mind giving their info. Of course you're gonna have to store a hashed value of the user id. – Olayinka Sep 19 '14 at 20:41
0

You could try to store a file outside of your app's data folder, which basically means external storage (like /sdcard). By it's nature, this directory is public and the file could be removed by the user. You would have to apply some encryption and give the file a name that seems like it's not part of your app or has any information that would influence the use of your app's feature, and hope that it doesn't get deleted somehow by the user.

Karakuri
  • 38,365
  • 12
  • 84
  • 104
0

This can be done by keeping track of two values (stored in sharedPreference).

Store your first launch date/time when the app is first launched (i.e. the value doesn't exist).
On every launch also store the current date/time (which should be called something like last launch date in your settings).

When starting, first check if the current date of the device is less than the stored last launch date - if it is then the user has changed the date/time - or procured a time travel device :) In this case you can display a warning message telling the user to behave, or just fail silently and prevent the user from accessing the feature(s).

If the date is okay, go ahead and update the value to the new current date (for future launches) and then check if the period has expired or not and make the feature available as needed.

This should work offline, except for users that have rooted their devices and can modify values in sharedPreference - but they should be a minority. To prevent root users, you will need to employ an online service.

Also just a warning that this can cause false positives when users travel (crossing time zones). But you should be able to handle that as a special case by also checking time zones (if needed).

free3dom
  • 18,729
  • 7
  • 52
  • 51