project_files/HedgewarsMobile/Classes/Appirater.m
changeset 8441 a00b0fa0dbd7
parent 6832 fae8fd118da9
child 11137 14f50dde3e8c
equal deleted inserted replaced
8440:ea4d6a7a2937 8441:a00b0fa0dbd7
     1 /*
     1 /*
     2  This file is part of Appirater, http://arashpayan.com
     2  This file is part of Appirater, http://arashpayan.com
     3  
     3 
     4  Copyright (c) 2010, Arash Payan
     4  Copyright (c) 2010, Arash Payan
     5  All rights reserved.
     5  All rights reserved.
     6  
     6 
     7  Permission is hereby granted, free of charge, to any person
     7  Permission is hereby granted, free of charge, to any person
     8  obtaining a copy of this software and associated documentation
     8  obtaining a copy of this software and associated documentation
     9  files (the "Software"), to deal in the Software without
     9  files (the "Software"), to deal in the Software without
    10  restriction, including without limitation the rights to use,
    10  restriction, including without limitation the rights to use,
    11  copy, modify, merge, publish, distribute, sublicense, and/or sell
    11  copy, modify, merge, publish, distribute, sublicense, and/or sell
    12  copies of the Software, and to permit persons to whom the
    12  copies of the Software, and to permit persons to whom the
    13  Software is furnished to do so, subject to the following
    13  Software is furnished to do so, subject to the following
    14  conditions:
    14  conditions:
    15  
    15 
    16  The above copyright notice and this permission notice shall be
    16  The above copyright notice and this permission notice shall be
    17  included in all copies or substantial portions of the Software.
    17  included in all copies or substantial portions of the Software.
    18  
    18 
    19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    20  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    20  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
    21  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    21  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    22  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    22  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    23  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    23  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    64     NSString *trackingVersion = [userDefaults stringForKey:kAppiraterCurrentVersion];
    64     NSString *trackingVersion = [userDefaults stringForKey:kAppiraterCurrentVersion];
    65     if (trackingVersion == nil) {
    65     if (trackingVersion == nil) {
    66         trackingVersion = version;
    66         trackingVersion = version;
    67         [userDefaults setObject:version forKey:kAppiraterCurrentVersion];
    67         [userDefaults setObject:version forKey:kAppiraterCurrentVersion];
    68     }
    68     }
    69     
    69 
    70     if (APPIRATER_DEBUG)
    70     if (APPIRATER_DEBUG)
    71         DLog(@"APPIRATER Tracking version: %@", trackingVersion);
    71         DLog(@"APPIRATER Tracking version: %@", trackingVersion);
    72 
    72 
    73     if ([trackingVersion isEqualToString:version]) {
    73     if ([trackingVersion isEqualToString:version]) {
    74         // get the launch date
    74         // get the launch date
    96 
    96 
    97         if (secondsSinceLaunch > secondsUntilPrompt &&
    97         if (secondsSinceLaunch > secondsUntilPrompt &&
    98              launchCount > LAUNCHES_UNTIL_PROMPT &&
    98              launchCount > LAUNCHES_UNTIL_PROMPT &&
    99              !declinedToRate &&
    99              !declinedToRate &&
   100              !ratedApp) {
   100              !ratedApp) {
   101             if ([HWUtils isNetworkReachable]) {	// check if they can reach the app store
   101             if ([HWUtils isNetworkReachable]) { // check if they can reach the app store
   102                 willShowPrompt = YES;
   102                 willShowPrompt = YES;
   103                 [self performSelectorOnMainThread:@selector(showPrompt) withObject:nil waitUntilDone:NO];
   103                 [self performSelectorOnMainThread:@selector(showPrompt) withObject:nil waitUntilDone:NO];
   104             }
   104             }
   105         }
   105         }
   106     } else {
   106     } else {
   139             break;
   139             break;
   140         case 1:
   140         case 1:
   141             // they want to rate it
   141             // they want to rate it
   142             [[UIApplication sharedApplication] openURL:
   142             [[UIApplication sharedApplication] openURL:
   143              [NSURL URLWithString:[templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", APPIRATER_APP_ID]]]];
   143              [NSURL URLWithString:[templateReviewURL stringByReplacingOccurrencesOfString:@"APP_ID" withString:[NSString stringWithFormat:@"%d", APPIRATER_APP_ID]]]];
   144             
   144 
   145             [userDefaults setBool:YES forKey:kAppiraterRatedCurrentVersion];
   145             [userDefaults setBool:YES forKey:kAppiraterRatedCurrentVersion];
   146             break;
   146             break;
   147         case 2:
   147         case 2:
   148             // remind them later
   148             // remind them later
   149             break;
   149             break;