Skip to content

Commit 27eaa6c

Browse files
committed
The version of Appirater compatible with PG added to Class folder.
Javascript interface for appEnteredForeground added.
1 parent 85e8977 commit 27eaa6c

File tree

6 files changed

+593
-1
lines changed

6 files changed

+593
-1
lines changed

iOS/AppiraterPlugin/AppiraterPlugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
//Significant Event Method
2121

2222
- (void) sigEvent:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
23+
- (void) foreground:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
2324
@end

iOS/AppiraterPlugin/AppiraterPlugin.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ var AppiraterPlugin = {
77

88
sigEvent: function() {
99
return Cordova.exec("AppiraterPlugin.sigEvent");
10+
},
11+
foreground: function() {
12+
return Cordova.exec("AppiraterPlugin.foreground");
1013
}
14+
1115
};

iOS/AppiraterPlugin/AppiraterPlugin.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ - (void) sigEvent:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)opti
1717
[Appirater userDidSignificantEvent:YES];
1818
}
1919

20+
- (void) foreground:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
21+
{
22+
[Appirater appEnteredForeground:NO];
23+
}
24+
2025
@end
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
/*
2+
This file is part of Appirater.
3+
4+
Copyright (c) 2012, Arash Payan
5+
All rights reserved.
6+
7+
Permission is hereby granted, free of charge, to any person
8+
obtaining a copy of this software and associated documentation
9+
files (the "Software"), to deal in the Software without
10+
restriction, including without limitation the rights to use,
11+
copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the
13+
Software is furnished to do so, subject to the following
14+
conditions:
15+
16+
The above copyright notice and this permission notice shall be
17+
included in all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26+
OTHER DEALINGS IN THE SOFTWARE.
27+
*/
28+
/*
29+
* Appirater.h
30+
* appirater
31+
*
32+
* Created by Arash Payan on 9/5/09.
33+
* http://arashpayan.com
34+
* Copyright 2012 Arash Payan. All rights reserved.
35+
*/
36+
37+
#import <Foundation/Foundation.h>
38+
39+
extern NSString *const kAppiraterFirstUseDate;
40+
extern NSString *const kAppiraterUseCount;
41+
extern NSString *const kAppiraterSignificantEventCount;
42+
extern NSString *const kAppiraterCurrentVersion;
43+
extern NSString *const kAppiraterRatedCurrentVersion;
44+
extern NSString *const kAppiraterDeclinedToRate;
45+
extern NSString *const kAppiraterReminderRequestDate;
46+
47+
/*
48+
Place your Apple generated software id here.
49+
*/
50+
#define APPIRATER_APP_ID 301377083
51+
52+
/*
53+
Your app's name.
54+
*/
55+
#define APPIRATER_APP_NAME [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey]
56+
57+
/*
58+
This is the message your users will see once they've passed the day+launches
59+
threshold.
60+
*/
61+
#define APPIRATER_LOCALIZED_MESSAGE NSLocalizedString(@"If you enjoy using %@, would you mind taking a moment to rate it? It won't take more than a minute. Thanks for your support!", nil)
62+
#define APPIRATER_MESSAGE [NSString stringWithFormat:APPIRATER_LOCALIZED_MESSAGE, APPIRATER_APP_NAME]
63+
64+
/*
65+
This is the title of the message alert that users will see.
66+
*/
67+
#define APPIRATER_LOCALIZED_MESSAGE_TITLE NSLocalizedString(@"Rate %@", nil)
68+
#define APPIRATER_MESSAGE_TITLE [NSString stringWithFormat:APPIRATER_LOCALIZED_MESSAGE_TITLE, APPIRATER_APP_NAME]
69+
70+
/*
71+
The text of the button that rejects reviewing the app.
72+
*/
73+
#define APPIRATER_CANCEL_BUTTON NSLocalizedString(@"No, Thanks", nil)
74+
75+
/*
76+
Text of button that will send user to app review page.
77+
*/
78+
#define APPIRATER_LOCALIZED_RATE_BUTTON NSLocalizedString(@"Rate %@", nil)
79+
#define APPIRATER_RATE_BUTTON [NSString stringWithFormat:APPIRATER_LOCALIZED_RATE_BUTTON, APPIRATER_APP_NAME]
80+
81+
/*
82+
Text for button to remind the user to review later.
83+
*/
84+
#define APPIRATER_RATE_LATER NSLocalizedString(@"Remind me later", nil)
85+
86+
/*
87+
Users will need to have the same version of your app installed for this many
88+
days before they will be prompted to rate it.
89+
*/
90+
#define APPIRATER_DAYS_UNTIL_PROMPT 30 // double
91+
92+
/*
93+
An example of a 'use' would be if the user launched the app. Bringing the app
94+
into the foreground (on devices that support it) would also be considered
95+
a 'use'. You tell Appirater about these events using the two methods:
96+
[Appirater appLaunched:]
97+
[Appirater appEnteredForeground:]
98+
99+
Users need to 'use' the same version of the app this many times before
100+
before they will be prompted to rate it.
101+
*/
102+
#define APPIRATER_USES_UNTIL_PROMPT 20 // integer
103+
104+
/*
105+
A significant event can be anything you want to be in your app. In a
106+
telephone app, a significant event might be placing or receiving a call.
107+
In a game, it might be beating a level or a boss. This is just another
108+
layer of filtering that can be used to make sure that only the most
109+
loyal of your users are being prompted to rate you on the app store.
110+
If you leave this at a value of -1, then this won't be a criteria
111+
used for rating. To tell Appirater that the user has performed
112+
a significant event, call the method:
113+
[Appirater userDidSignificantEvent:];
114+
*/
115+
#define APPIRATER_SIG_EVENTS_UNTIL_PROMPT -1 // integer
116+
117+
/*
118+
Once the rating alert is presented to the user, they might select
119+
'Remind me later'. This value specifies how long (in days) Appirater
120+
will wait before reminding them.
121+
*/
122+
#define APPIRATER_TIME_BEFORE_REMINDING 1 // double
123+
124+
/*
125+
'YES' will show the Appirater alert everytime. Useful for testing how your message
126+
looks and making sure the link to your app's review page works.
127+
*/
128+
#define APPIRATER_DEBUG NO
129+
130+
@interface Appirater : NSObject <UIAlertViewDelegate> {
131+
132+
UIAlertView *ratingAlert;
133+
}
134+
135+
@property(nonatomic, retain) UIAlertView *ratingAlert;
136+
137+
/*
138+
DEPRECATED: While still functional, it's better to use
139+
appLaunched:(BOOL)canPromptForRating instead.
140+
141+
Calls [Appirater appLaunched:YES]. See appLaunched: for details of functionality.
142+
*/
143+
+ (void)appLaunched;
144+
145+
/*
146+
Tells Appirater that the app has launched, and on devices that do NOT
147+
support multitasking, the 'uses' count will be incremented. You should
148+
call this method at the end of your application delegate's
149+
application:didFinishLaunchingWithOptions: method.
150+
151+
If the app has been used enough to be rated (and enough significant events),
152+
you can suppress the rating alert
153+
by passing NO for canPromptForRating. The rating alert will simply be postponed
154+
until it is called again with YES for canPromptForRating. The rating alert
155+
can also be triggered by appEnteredForeground: and userDidSignificantEvent:
156+
(as long as you pass YES for canPromptForRating in those methods).
157+
*/
158+
+ (void)appLaunched:(BOOL)canPromptForRating;
159+
160+
/*
161+
Tells Appirater that the app was brought to the foreground on multitasking
162+
devices. You should call this method from the application delegate's
163+
applicationWillEnterForeground: method.
164+
165+
If the app has been used enough to be rated (and enough significant events),
166+
you can suppress the rating alert
167+
by passing NO for canPromptForRating. The rating alert will simply be postponed
168+
until it is called again with YES for canPromptForRating. The rating alert
169+
can also be triggered by appLaunched: and userDidSignificantEvent:
170+
(as long as you pass YES for canPromptForRating in those methods).
171+
*/
172+
+ (void)appEnteredForeground:(BOOL)canPromptForRating;
173+
174+
/*
175+
Tells Appirater that the user performed a significant event. A significant
176+
event is whatever you want it to be. If you're app is used to make VoIP
177+
calls, then you might want to call this method whenever the user places
178+
a call. If it's a game, you might want to call this whenever the user
179+
beats a level boss.
180+
181+
If the user has performed enough significant events and used the app enough,
182+
you can suppress the rating alert by passing NO for canPromptForRating. The
183+
rating alert will simply be postponed until it is called again with YES for
184+
canPromptForRating. The rating alert can also be triggered by appLaunched:
185+
and appEnteredForeground: (as long as you pass YES for canPromptForRating
186+
in those methods).
187+
*/
188+
+ (void)userDidSignificantEvent:(BOOL)canPromptForRating;
189+
190+
/*
191+
Tells Appirater to open the App Store page where the user can specify a
192+
rating for the app. Also records the fact that this has happened, so the
193+
user won't be prompted again to rate the app.
194+
195+
The only case where you should call this directly is if your app has an
196+
explicit "Rate this app" command somewhere. In all other cases, don't worry
197+
about calling this -- instead, just call the other functions listed above,
198+
and let Appirater handle the bookkeeping of deciding when to ask the user
199+
whether to rate the app.
200+
*/
201+
+ (void)rateApp;
202+
203+
@end

0 commit comments

Comments
 (0)