4

I am developing an iDevice application.I want to make it such that the User of this application can download this app for free from iTunes but after trial period of 1 week , User will be asked to purchase the app. If the User will not purchase it , then he/she will not be allowed to use the app

  • 5
    Apple will remove apps that do the following: Apps containing "rental" content or services that expire after a limited time are not permitted and Apps that are "beta", "demo", "trial", or "test" versions are not permitted – iProgrammed Jan 26 '13 at 06:29

3 Answers3

4

Use the Keychain to store the date they installed the app. The values your app adds to the keychain persist after your app is uninstalled and can be accessed again upon re-install.

https://developer.apple.com/library/ios/#documentation/Security/Reference/keychainservices/Reference/reference.html#//apple_ref/doc/uid/TP30000898-CH4g-SW7

Erik Nedwidek
  • 6,134
  • 1
  • 25
  • 25
  • 1
    And they are also exposed to being read/modified by [this](https://github.com/ptoomey3/Keychain-Dumper)... –  Jan 26 '13 at 06:25
  • @H2CO3 you failed to mention the minor detail that the device has to be jailbroken. – Gabriele Petronella Jan 26 '13 at 06:26
  • 1
    @GabrielePetronella That's not minor. There are lots of jailbroken devices out there. –  Jan 26 '13 at 06:27
  • 2
    @GabrielePetronella Security holes and sarcasm are never minor (meta). – CodaFi Jan 26 '13 at 06:28
  • @H2CO3 exactly: not a minor detail at all, but kind of a huge difference. This solution can be overcome with with a jailbroken device as much as the app itself can be downloaded illegally. Still the solution is valid and reasonable. – Gabriele Petronella Jan 26 '13 at 06:31
  • @GabrielePetronella My principle: why implement something if you **know** it's going to be *very* insecure? There should be at least one more level of security that deals with the potential access to the data of the app. –  Jan 26 '13 at 06:33
  • how can i get the date from keychain? could you please provide me the code? –  Jan 26 '13 at 06:36
  • @H2CO3 It depends what your target is. We are talking about enabling a trial period, not storing secret military plans. There's no need to over-engineer such a simple mechanism, before encountering any issue with that. Jailbroken device are a very restricted minority after all – Gabriele Petronella Jan 26 '13 at 06:37
  • 1
    As soon as the device is rooted, the game is up. It's all about difficulty level. Even if you put the date in with a signature that was generated by a private key on your own licensing server, they can still remove that code from your app. Requires knowledge and skill. It's all about how far do you feel like going. – Erik Nedwidek Jan 26 '13 at 06:49
  • As far as code goes, I've never worked with the Keychain, I just know of its existence and you'll need to hunt for code or read the docs. – Erik Nedwidek Jan 26 '13 at 06:50
  • will it support in ios6 also? –  Jan 26 '13 at 07:07
  • How can i identify differnt user's device using keychain? –  Jan 26 '13 at 08:16
  • Keychain is in iOS 2.0 and up. You want the device's UUID. http://mobiledevelopertips.com/device/get-iphone-device-name-unique-device-identifier-udid-os-and-model.html – Erik Nedwidek Jan 26 '13 at 22:36
  • Can't the user get around a date check like this by simply modifying the date in Settings? No rooting required. – JohnK Jul 08 '13 at 16:22
4

One option could be the one proposed by AKV: save the time in the NSUserDefaults and check it at every launch.

The weak point is that a user could reset the trial period by reinstalling the app from the AppStore.

A good option would be to use the keychain, which should be persistent across multiple installation of the app.

Alternatively you could to store a unique identifier of the device on your server and check it at every app launch.

The downside of this solution is that it requires an active internet connection, but it will prevent users to easily go around it.

As a final remark it is possible that Apple won't accept an application with such a behaviour. Usually applications are required not to disable functionalities over time, even if some border line cases may apply. The review guidelines may have changed recently, but as far as I know they state clearly

Apps containing "rental" content or services that expire after a limited time will be rejected

Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
0

Save the date time in user defaults.

On each launch of app go on to check if the dateDiffernce is not more than 30 days. If it is more show a popup as ask user to buy the app. and disable all functionalites.

EDIT: In my early days we did a lot of such tweaks for windows, trial ware games and applications. But you lose your saved data with reinstalling the app again. If you still insist not to allow then you can write it in Keychain or some file in documents instead of user-defaults and plist. But for some extent it is not allowed by Apple to have such an application.

xpda
  • 15,585
  • 8
  • 51
  • 82
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
  • 1
    What if the user will remove the app after trial period and then download it again from iTunes? –  Jan 26 '13 at 06:05
  • 1
    My advice - focus on a good user experience for the ones who do pay, not blocking the ones who don't. Deleting and re-adding an app every week will get really annoying after a while. – DrC Jan 26 '13 at 06:10
  • @A12388: In my early days we did a lot of such tweaks for windows, trial ware games and applications. But you loose your saved data with reinstaling the app again. If you still insist not to allow then you can write some file in documents instead of user-defaults and plist. – Anoop Vaidya Jan 26 '13 at 06:13