refactor: Code to show/hide banner for Pro version is now more simple

This commit is contained in:
Andrea Busi
2020-07-30 15:24:44 +02:00
parent 9f7545ddb7
commit 437e2da81b
7 changed files with 17 additions and 36 deletions
-1
View File
@@ -316,7 +316,6 @@ typedef enum : NSInteger {
#define EQN_ADMOB_ANNUNCIO_IDA_TEST @"ca-app-pub-3940256099942544/2934735716"
// ACQUISTI IN APP
#define EQN_ACQ_IN_APP @"EQN_ACQ_IN_APP"
#define CONTEGGIO_APERTURE_PER_SCONTO @"CONTEGGIO_APERTURE_PER_SCONTO"
#define PREZZO_SCONTATO_SCADUTO @"PREZZO_SCONTATO_SCADUTO"
#define IAPHelperPurchaseNotification @"IAPHelperPurchaseNotification"
@@ -57,12 +57,7 @@
[self.buttonAzione addTarget:self action:@selector(visualizzaPikerFiltro:) forControlEvents:UIControlEventTouchDown];
[self applicaFiltroWithTime:@(2)];
if ([[NSUserDefaults standardUserDefaults] boolForKey:EQN_ACQ_IN_APP])
NSLog(@"ciao");
else
self.bannerView = [EQNUtility ottieniBannerWithController:self position:NO];
self.bannerView = [EQNUtility ottieniBannerWithController:self position:NO];
}
- (void)didReceiveMemoryWarning {
@@ -36,10 +36,7 @@
}
if (![[NSUserDefaults standardUserDefaults] boolForKey:EQN_ACQ_IN_APP]){
self.bannerView = [EQNUtility ottieniBannerWithController:self position:YES];
}
self.bannerView = [EQNUtility ottieniBannerWithController:self position:YES];
}
- (void)didReceiveMemoryWarning {
@@ -49,10 +49,7 @@
[self.buttonAzione addTarget:self action:@selector(visualizzaPikerFiltro:) forControlEvents:UIControlEventTouchDown];
[self applicaFiltroWithTime:@(0)];
if (![[NSUserDefaults standardUserDefaults] boolForKey:EQN_ACQ_IN_APP]){
self.bannerView = [EQNUtility ottieniBannerWithController:self position:NO];
}
self.bannerView = [EQNUtility ottieniBannerWithController:self position:NO];
}
- (void)didReceiveMemoryWarning {
@@ -49,27 +49,17 @@
[self sincronizza];
// check for an AppStore receipt
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
if (!receipt) { /* No local receipt -- handle the error. */
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:EQN_ACQ_IN_APP];
self.bannerView = [EQNUtility ottieniBannerWithController:self position:YES];
} else {
if (receipt) {
[[ServerRequest defaultServerConnectionSingleton] inviaRicevuta:receipt success:^(id result) {
// nope
} failure:^(NSError *error) {
// nope
}];
}
/* ... Send the receipt data to your server ... */
SWRevealViewController *revealViewController = self.revealViewController;
if ( revealViewController )
{
@@ -105,9 +95,7 @@
[self caricaChildrenViewController:[NSIndexPath indexPathForRow:0 inSection:0]];
if (![[NSUserDefaults standardUserDefaults] boolForKey:EQN_ACQ_IN_APP]){
self.bannerView = [EQNUtility ottieniBannerWithController:self position:YES];
}
self.bannerView = [EQNUtility ottieniBannerWithController:self position:YES];
}
-(void)registraNotifiche{
@@ -12,6 +12,8 @@
#import "MasterViewController.h"
@import GoogleMobileAds;
NS_ASSUME_NONNULL_BEGIN
@interface EQNUtility : NSObject
+(NSDate *)getDataFromString:(NSString *)stringData;
@@ -34,7 +36,13 @@
+(UIViewController *)shareFileWithPath:(id)path;
+(NSArray *)arrayDescrizioneEnti;
+(GADBannerView *)ottieniBannerWithController:(UIViewController *)controller position:(BOOL)isButton;
/// Creates Ad-sense banner to show on a given controller
/// This method returns nil if the user has a Pro version, no banner has to be shown
/// @param controller Controller
/// @param isButton Is button
+(nullable GADBannerView *)ottieniBannerWithController:(UIViewController *)controller position:(BOOL)isButton;
@end
NS_ASSUME_NONNULL_END
@@ -373,9 +373,6 @@
+(GADBannerView *)ottieniBannerWithController:(UIViewController *)controller position:(BOOL)isButton
{
if ([EQNPurchaseUtility isProVersionEnabled]) {
[[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:EQN_ACQ_IN_APP];
[[NSUserDefaults standardUserDefaults] synchronize];
return nil;
}