Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HypRate functionality on iOS #2

Open
wants to merge 14 commits into
base: haxe3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions include.nmml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
<!-- misc -->
<classpath name="src" />

<!-- Mobile -->
<!-- iOS -->
<ndll name="HypRate" if="ios" />
<dependency name="StoreKit.framework" if="ios" />
<dependency name="SystemConfiguration.framework" if="ios" />


<!-- Android -->
<java path="project/android" />
<templatePath name="templates" />
</project>
</project>
Binary file modified ndll/iPhone/libHypRate.iphoneos-v7.a
Binary file not shown.
Binary file modified ndll/iPhone/libHypRate.iphoneos.a
Binary file not shown.
Binary file modified ndll/iPhone/libHypRate.iphonesim.a
Binary file not shown.
1 change: 1 addition & 0 deletions project/Build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<compilerflag value="-IiPhone/include"/>
<compilerflag value="-Iinclude"/>
<file name="iPhone/HypRate.mm"/>
<file name="iPhone/include/Appirater.m"/>
</files>

<target id="NDLL" output="${name_prefix}HypRate${name_extra}" tool="linker" toolid="${ndll-tool}">
Expand Down
12 changes: 11 additions & 1 deletion project/android/fr/hyperfiction/HypRate.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ static public void show( ) {
rmm.forceShow( );
}

/**
*
*
* @public
* @return void
*/
static public void setAppId( String appId ){
trace("setAppId does nothing on Android");
}

/**
*
*
Expand Down Expand Up @@ -128,4 +138,4 @@ static public void setNegative_text( String s ){
public static void trace( String s ){
Log.w( TAG, "HypFacebookFrag ::: "+s );
}
}
}
21 changes: 13 additions & 8 deletions project/common/ExternalInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,51 @@ extern "C"{
// iPhone ---------------------------------------------------------------------------------------------------------

#ifdef IPHONE
value HypRate_setAppId( value s ) {
Hyperfiction::setAppId( val_string( s ) );
return alloc_null( );
}
DEFINE_PRIM( HypRate_setAppId , 1 );

value HypRate_setDialog_title( value s ) {
setDialog_title( val_string( s ) );
Hyperfiction::setDialog_title( val_string( s ) );
return alloc_null( );
}
DEFINE_PRIM( HypRate_setDialog_title , 1 );

value HypRate_setDialog_msg( value s ) {
setDialog_msg( val_string( s ) );
Hyperfiction::setDialog_msg( val_string( s ) );
return alloc_null( );
}
DEFINE_PRIM( HypRate_setDialog_msg , 1 );

value HypRate_setPositive_text( value s ) {
setPositive_text( val_string( s ) );
Hyperfiction::setPositive_text( val_string( s ) );
return alloc_null( );
}
DEFINE_PRIM( HypRate_setPositive_text , 1 );

value HypRate_setNeutral_text( value s ) {
setNeutral_text( val_string( s ) );
Hyperfiction::setNeutral_text( val_string( s ) );
return alloc_null( );
}
DEFINE_PRIM( HypRate_setNeutral_text , 1 );

value HypRate_setNegative_text( value s ) {
setCancel_text( val_string( s ) );
Hyperfiction::setCancel_text( val_string( s ) );
return alloc_null( );
}
DEFINE_PRIM( HypRate_setNegative_text , 1 );

value HypRate_start( value minL , value minD , value untilL , value untilD ){
start( val_int( minL ) , val_int( minD ) , val_int( untilL ) , val_int( untilD ));
Hyperfiction::start( val_int( minL ) , val_int( minD ) , val_int( untilL ) , val_int( untilD ));
return alloc_null( );
}
DEFINE_PRIM( HypRate_start , 4 );

value HypRate_show( ){
show( );
return alloc_nul( );
Hyperfiction::show( );
return alloc_null( );
}
DEFINE_PRIM( HypRate_show , 0 );

Expand Down
25 changes: 18 additions & 7 deletions project/iPhone/HypRate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,19 @@
*/
#import <UIKit/UIKit.h>
#include <HypRate.h>
#include "include/Appirater.h"
namespace Hyperfiction{

/**
*
*
* @public
* @return void
*/
void setAppId( const char *s ){
[Appirater setAppId:[[[NSString alloc] initWithUTF8String:s] autorelease]];
}

/**
*
*
Expand Down Expand Up @@ -62,19 +73,19 @@ void setNeutral_text( const char *s ){
void setCancel_text( const char *s ){
[Appirater setCancel_text:[[[NSString alloc] initWithUTF8String:s] autorelease]];
}

/**
*
*
* @public
* @return void
*/
void start( int minL , int minD , int untilL , int unitD ){
[Appirater setAppId:@"552035781"];
[Appirater setDaysUntilPrompt:1];
[Appirater setUsesUntilPrompt:10];
[Appirater setUsesUntilPrompt:minL];
[Appirater setDaysUntilPrompt:minD];
// Disable significant event criterion
[Appirater setSignificantEventsUntilPrompt:-1];
[Appirater setTimeBeforeReminding:2];
[Appirater setTimeBeforeReminding:unitD];
[Appirater setDebug:YES];
}

Expand All @@ -85,8 +96,8 @@ void start( int minL , int minD , int untilL , int unitD ){
* @return void
*/
void show( ){
//showPrompt( )
[Appirater showPrompt];
}


}
}
85 changes: 69 additions & 16 deletions project/iPhone/include/Appirater.h
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
This file is part of Appirater.

Copyright (c) 2012, Arash Payan
All rights reserved.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
Expand All @@ -12,10 +12,10 @@
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Expand Down Expand Up @@ -46,12 +46,52 @@ extern NSString *const kAppiraterRatedCurrentVersion;
extern NSString *const kAppiraterDeclinedToRate;
extern NSString *const kAppiraterReminderRequestDate;

/*
Your localized app's name.
*/
#define APPIRATER_LOCALIZED_APP_NAME [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"]

/*
Your app's name.
*/
#define APPIRATER_APP_NAME APPIRATER_LOCALIZED_APP_NAME ? APPIRATER_LOCALIZED_APP_NAME : [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]

/*
This is the message your users will see once they've passed the day+launches
threshold.
*/
#define APPIRATER_LOCALIZED_MESSAGE NSLocalizedStringFromTableInBundle(@"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!", @"AppiraterLocalizable", [Appirater bundle], nil)
#define APPIRATER_MESSAGE [NSString stringWithFormat:APPIRATER_LOCALIZED_MESSAGE, APPIRATER_APP_NAME]

/*
This is the title of the message alert that users will see.
*/
#define APPIRATER_LOCALIZED_MESSAGE_TITLE NSLocalizedStringFromTableInBundle(@"Rate %@", @"AppiraterLocalizable", [Appirater bundle], nil)
#define APPIRATER_MESSAGE_TITLE [NSString stringWithFormat:APPIRATER_LOCALIZED_MESSAGE_TITLE, APPIRATER_APP_NAME]

/*
The text of the button that rejects reviewing the app.
*/
#define APPIRATER_CANCEL_BUTTON NSLocalizedStringFromTableInBundle(@"No, Thanks", @"AppiraterLocalizable", [Appirater bundle], nil)

/*
Text of button that will send user to app review page.
*/
#define APPIRATER_LOCALIZED_RATE_BUTTON NSLocalizedStringFromTableInBundle(@"Rate %@", @"AppiraterLocalizable", [Appirater bundle], nil)
#define APPIRATER_RATE_BUTTON [NSString stringWithFormat:APPIRATER_LOCALIZED_RATE_BUTTON, APPIRATER_APP_NAME]

/*
Text for button to remind the user to review later.
*/
#define APPIRATER_RATE_LATER NSLocalizedStringFromTableInBundle(@"Remind me later", @"AppiraterLocalizable", [Appirater bundle], nil)

@interface Appirater : NSObject <UIAlertViewDelegate, SKStoreProductViewControllerDelegate> {

UIAlertView *ratingAlert;
}

@property(nonatomic, strong) UIAlertView *ratingAlert;
@property(nonatomic) BOOL openInAppStore;
#if __has_feature(objc_arc_weak)
@property(nonatomic, weak) NSObject <AppiraterDelegate> *delegate;
#else
Expand All @@ -63,7 +103,7 @@ extern NSString *const kAppiraterReminderRequestDate;
support multitasking, the 'uses' count will be incremented. You should
call this method at the end of your application delegate's
application:didFinishLaunchingWithOptions: method.

If the app has been used enough to be rated (and enough significant events),
you can suppress the rating alert
by passing NO for canPromptForRating. The rating alert will simply be postponed
Expand All @@ -77,7 +117,7 @@ extern NSString *const kAppiraterReminderRequestDate;
Tells Appirater that the app was brought to the foreground on multitasking
devices. You should call this method from the application delegate's
applicationWillEnterForeground: method.

If the app has been used enough to be rated (and enough significant events),
you can suppress the rating alert
by passing NO for canPromptForRating. The rating alert will simply be postponed
Expand All @@ -93,7 +133,7 @@ extern NSString *const kAppiraterReminderRequestDate;
calls, then you might want to call this method whenever the user places
a call. If it's a game, you might want to call this whenever the user
beats a level boss.

If the user has performed enough significant events and used the app enough,
you can suppress the rating alert by passing NO for canPromptForRating. The
rating alert will simply be postponed until it is called again with YES for
Expand All @@ -107,7 +147,7 @@ extern NSString *const kAppiraterReminderRequestDate;
Tells Appirater to show the prompt (a rating alert). The prompt will be showed
if there is connection available, the user hasn't declined to rate
or hasn't rated current version.

You could call to show the prompt regardless Appirater settings,
e.g., in case of some special event in your app.
*/
Expand Down Expand Up @@ -152,7 +192,7 @@ extern NSString *const kAppiraterReminderRequestDate;
a 'use'. You tell Appirater about these events using the two methods:
[Appirater appLaunched:]
[Appirater appEnteredForeground:]

Users need to 'use' the same version of the app this many times before
before they will be prompted to rate it.
*/
Expand Down Expand Up @@ -200,23 +240,36 @@ extern NSString *const kAppiraterReminderRequestDate;
*/
+ (void)setOpenInAppStore:(BOOL)openInAppStore;

+(void) setCancel_text:(NSString)value;
+(void) setRate_text:(NSString)value;
+(void) setMsg_text:(NSString)value;
+(void) setRate_text:(NSString)value;
+(void) setTitle_text:(NSString)value;
/*
If set to YES, the main bundle will always be used to load localized strings.
Set this to YES if you have provided your own custom localizations in AppiraterLocalizable.strings
in your main bundle. Default is NO.
*/
+ (void)setAlwaysUseMainBundle:(BOOL)useMainBundle;

@end


/*
Methods in this interface are public out of necessity, but may change without notice
*/
@interface Appirater(Unsafe)

/*
The bundle localized strings will be loaded from.
*/
+(NSBundle *)bundle;

@end

@interface Appirater(Deprecated)

/*
DEPRECATED: While still functional, it's better to use
appLaunched:(BOOL)canPromptForRating instead.

Calls [Appirater appLaunched:YES]. See appLaunched: for details of functionality.
*/
+ (void)appLaunched __attribute__((deprecated));
+ (void)appLaunched __attribute__((deprecated));

@end
Loading