[Solved] How to make a iOS App which only runs for e.g. 1 Day? [closed]


USE ONLY IF YOU WANT TO USE IT AS INHOUSE APP.

Write following code in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method

if (![[NSUserDefaults standardUserDefaults] objectForKey:IS_APP_RUNNING_FIRST_TIME])
{
    [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:IS_APP_RUNNING_FIRST_TIME];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
else
{
    NSDate * firstDate = [[NSUserDefaults standardUserDefaults] objectForKey:IS_APP_RUNNING_FIRST_TIME];
    NSDate * todayDate = [NSDate date];

    NSCalendar *gregorian = [[NSCalendar alloc]
                             initWithCalendarIdentifier:NSGregorianCalendar];

    NSUInteger unitFlags = NSHourCalendarUnit;

    NSDateComponents *components = [gregorian components:unitFlags
                                                fromDate:firstDate
                                                  toDate:todayDate options:0];
    NSInteger hours = [components hour];
    if (hours>24)
    {
        // Apple can reject exit(0);
        //USE ONLY IF YOU WANT TO USE IT AS INHOUSE APP
        exit(0); 
    }
}

5

solved How to make a iOS App which only runs for e.g. 1 Day? [closed]