#239: Removed Subscription

This commit is contained in:
Patrick Santana 2013-10-25 16:14:29 -02:00
parent 6e730b95fa
commit 7c80009425
15 changed files with 15 additions and 629 deletions

View file

@ -37,11 +37,7 @@
#import <Crashlytics/Crashlytics.h>
//for payment
#import <StoreKit/StoreKit.h>
#import "TroveboxPaymentTransactionObserver.h"
#import "TroveboxSubscription.h"
// sharing
#import "SHK.h"
#import "SHKItem.h"
#import "SHKTwitter.h"

View file

@ -122,20 +122,9 @@ static const NSInteger kGANDispatchPeriodSec = 10;
// start the job
[[JobUploaderController getController] start];
// Let the device know we want to receive push notifications
// [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
// (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
// remove badges
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
// Payment setup
if ([SKPaymentQueue canMakePayments]) {
TroveboxSubscription *subscription = [TroveboxSubscription troveboxSubscription];
[subscription requestProUpgradeProductData];
[[SKPaymentQueue defaultQueue] addTransactionObserver:[TroveboxPaymentTransactionObserver troveboxPaymentTransactionObserver]];
}
return YES;
}

View file

@ -24,7 +24,7 @@
#import "PhotoUploader.h"
@interface PhotoViewController : GAITrackedViewController <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate, UIAlertViewDelegate>
@interface PhotoViewController : GAITrackedViewController <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>
@property (nonatomic, weak) IBOutlet UITableView *detailsPictureTable;

View file

@ -171,18 +171,6 @@
}
self.labelLimitUpload.text = message;
if ([SharedAppDelegate limitFreeUser] == 0){
// limit reached,
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: NSLocalizedString(@"Limit reached", nil)
message: [NSString stringWithFormat:NSLocalizedString(@"You've reached your monthly limit of %d photos. Upgrade today for an unlimited Pro account.",@"Message when limit is reached"), [SharedAppDelegate limitAllowed]]
delegate:self
cancelButtonTitle:NSLocalizedString(@"OK",nil)
otherButtonTitles:NSLocalizedString(@"Upgrade",nil), nil];
[alert show];
//disable button
self.navigationItem.rightBarButtonItem.enabled = FALSE;
}
}
}
@ -511,11 +499,4 @@
}
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1){
[(MenuViewController*) SharedAppDelegate.menuController displayProfileScreen];
}
}
@end

View file

@ -23,16 +23,11 @@
// image cache
#import <SDWebImage/UIImageView+WebCache.h>
//for payment
#import "SKProduct+LocalizedPrice.h"
#import "TroveboxSubscription.h"
// for clean the cache
#import "Timeline+Methods.h"
#import <SDWebImage/SDImageCache.h>
#import <QuartzCore/QuartzCore.h>
#import "WebViewController.h"
@interface ProfileViewController : GAITrackedViewController <UIAlertViewDelegate>
@ -45,11 +40,5 @@
@property (nonatomic, weak) IBOutlet UILabel *labelStorageDetails;
@property (nonatomic, weak) IBOutlet UILabel *labelServer;
@property (nonatomic, weak) IBOutlet UILabel *labelAccount;
@property (nonatomic, weak) IBOutlet UILabel *labelPriceSubscription;
@property (nonatomic, weak) IBOutlet UIButton *buttonSubscription;
- (IBAction)subscribe:(id)sender;
- (IBAction)openFeaturesList:(id)sender;
@property (nonatomic, weak) IBOutlet UIButton *buttonFeatureList;
@end

View file

@ -39,13 +39,6 @@
self.wantsFullScreenLayout = YES;
self.view.backgroundColor = UIColorFromRGB(0XFAF3EF);
// needs update in screen
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(eventHandler:)
name:kInAppPurchaseManagerProductsFetchedNotification
object:nil ];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(eventHandler:)
name:kNotificationProfileRemoveProgressBar
@ -234,31 +227,6 @@
}
[MBProgressHUD hideHUDForView:self.navigationController.view animated:YES];
if ([SKPaymentQueue canMakePayments]) {
if (![SharedAppDelegate isHosted] || [[result objectForKey:@"paid"] boolValue]){
// PRO User, don't show button or label
self.labelPriceSubscription.hidden = TRUE;
self.buttonSubscription.hidden = TRUE;
self.buttonFeatureList.hidden = TRUE;
}else{
// set the value
TroveboxSubscription *subscription = [TroveboxSubscription troveboxSubscription];
SKProduct *product = [subscription product];
if( product.price != nil){
[self.labelPriceSubscription setText:[NSString stringWithFormat:@"%@ %@/%@", NSLocalizedString(@"Just",@"Profile - subscription"), [product localizedPrice], NSLocalizedString(@"month",@"Profile - subscription")]];
self.buttonFeatureList.hidden = FALSE;
self.labelPriceSubscription.hidden = FALSE;
self.buttonSubscription.hidden = FALSE;
}}
}else{
// Warn the user that purchases are disabled.
PhotoAlertView *alert = [[PhotoAlertView alloc] initWithMessage: NSLocalizedString(@"App can't do Purchase. Please, check Settings if you want to upgrade the app",@"Message when user can not purchase") duration:7000];
[alert showAlert];
[self.buttonSubscription setHidden:YES];
[self.labelPriceSubscription setHidden:YES];
}
});
}@catch (NSException* e) {
dispatch_async(dispatch_get_main_queue(), ^{
@ -273,23 +241,6 @@
}
- (IBAction)subscribe:(id)sender {
if ([SKPaymentQueue canMakePayments]) {
SKPayment *payment = [SKPayment paymentWithProduct:[TroveboxSubscription troveboxSubscription].proUpgradeProduct];
[[SKPaymentQueue defaultQueue] transactions];
[[SKPaymentQueue defaultQueue] addPayment:payment];
[MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
}
}
- (IBAction)openFeaturesList:(id)sender
{
// open a web view for the link: https://trovebox.com/plans/mobile
WebViewController* webViewController = [[WebViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:webViewController animated:YES];
}
- (void) formatStorage:(long long) storage
{
int kb = 1024;
@ -316,9 +267,7 @@
NSLog(@"###### Event triggered: %@", notification);
#endif
if ([notification.name isEqualToString:kInAppPurchaseManagerProductsFetchedNotification]){
[self loadUserDetails];
}else if ([notification.name isEqualToString:kNotificationProfileRemoveProgressBar]){
if ([notification.name isEqualToString:kNotificationProfileRemoveProgressBar]){
[MBProgressHUD hideHUDForView:self.navigationController.view animated:YES];
}
}
@ -334,9 +283,7 @@
[self setLabelStorageDetails:nil];
[self setLabelServer:nil];
[self setLabelAccount:nil];
[self setLabelPriceSubscription:nil];
[self setButtonSubscription:nil];
[self setButtonFeatureList:nil];
[super viewDidUnload];
}
@end

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="12F45" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4510" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment defaultVersion="1792" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
@ -7,13 +7,10 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ProfileViewController">
<connections>
<outlet property="buttonFeatureList" destination="87" id="89"/>
<outlet property="buttonSubscription" destination="74" id="78"/>
<outlet property="labelAccount" destination="71" id="73"/>
<outlet property="labelAlbums" destination="24" id="43"/>
<outlet property="labelName" destination="41" id="48"/>
<outlet property="labelPhotos" destination="37" id="44"/>
<outlet property="labelPriceSubscription" destination="75" id="77"/>
<outlet property="labelServer" destination="70" id="72"/>
<outlet property="labelStorage" destination="39" id="46"/>
<outlet property="labelStorageDetails" destination="31" id="64"/>
@ -119,47 +116,10 @@
<color key="textColor" red="0.55294120309999995" green="0.48235297199999999" blue="0.45490199329999997" alpha="1" colorSpace="deviceRGB"/>
<nil key="highlightedColor"/>
</label>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="74">
<rect key="frame" x="2" y="355" width="318" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" image="profile-button-upgrade-pro.png">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="subscribe:" destination="-1" eventType="touchUpInside" id="79"/>
</connections>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="75">
<rect key="frame" x="20" y="398" width="281" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="center" image="profile-line.png" id="76">
<rect key="frame" x="216" y="179" width="26" height="73"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="infoDark" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="87">
<rect key="frame" x="248" y="399" width="22" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="openFeaturesList:" destination="-1" eventType="touchUpInside" id="88"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
@ -169,7 +129,6 @@
</objects>
<resources>
<image name="profile-albumsico.png" width="26" height="26"/>
<image name="profile-button-upgrade-pro.png" width="282" height="37"/>
<image name="profile-details-server-account.png" width="314" height="87"/>
<image name="profile-line.png" width="3" height="57"/>
<image name="profile-photosico.png" width="31" height="26"/>

View file

@ -1,19 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="4510" systemVersion="12F37" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="4510" systemVersion="13A603" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none">
<dependencies>
<deployment defaultVersion="1536" identifier="iOS"/>
<deployment defaultVersion="1792" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3742"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ProfileViewController">
<connections>
<outlet property="buttonFeatureList" destination="23" id="26"/>
<outlet property="buttonSubscription" destination="20" id="27"/>
<outlet property="labelAccount" destination="19" id="35"/>
<outlet property="labelAlbums" destination="8" id="30"/>
<outlet property="labelName" destination="11" id="34"/>
<outlet property="labelPhotos" destination="7" id="31"/>
<outlet property="labelPriceSubscription" destination="21" id="38"/>
<outlet property="labelServer" destination="18" id="36"/>
<outlet property="labelStorage" destination="10" id="33"/>
<outlet property="labelStorageDetails" destination="5" id="32"/>
@ -119,47 +116,10 @@
<color key="textColor" red="0.55294120309999995" green="0.48235297199999999" blue="0.45490199329999997" alpha="1" colorSpace="deviceRGB"/>
<nil key="highlightedColor"/>
</label>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="20">
<rect key="frame" x="225" y="551" width="318" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" image="profile-button-upgrade-pro.png">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="subscribe:" destination="-1" eventType="touchUpInside" id="29"/>
</connections>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="21">
<rect key="frame" x="244" y="603" width="281" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="center" image="profile-line.png" id="22">
<rect key="frame" x="470" y="296" width="50" height="114"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="infoDark" showsTouchWhenHighlighted="YES" lineBreakMode="middleTruncation" id="23">
<rect key="frame" x="549" y="563" width="22" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="openFeaturesList:" destination="-1" eventType="touchUpInside" id="28"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics" statusBarStyle="blackOpaque"/>
@ -169,7 +129,6 @@
</objects>
<resources>
<image name="profile-albumsico.png" width="26" height="26"/>
<image name="profile-button-upgrade-pro.png" width="282" height="37"/>
<image name="profile-details-server-account.png" width="314" height="87"/>
<image name="profile-line.png" width="3" height="57"/>
<image name="profile-photosico.png" width="31" height="26"/>

View file

@ -1,28 +0,0 @@
//
// SKProduct+LocalizedPrice.h
// Trovebox
//
// Created by Patrick Santana on 25/02/13.
// Copyright 2013 Trovebox
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
@interface SKProduct (LocalizedPrice)
@property (nonatomic, readonly) NSString *localizedPrice;
@end

View file

@ -1,35 +0,0 @@
//
// SKProduct+LocalizedPrice.m
// Trovebox
//
// Created by Patrick Santana on 25/02/13.
// Copyright 2013 Trovebox
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "SKProduct+LocalizedPrice.h"
#import <StoreKit/StoreKit.h>
@implementation SKProduct (LocalizedPrice)
- (NSString *)localizedPrice
{
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:self.priceLocale];
return [numberFormatter stringFromNumber:self.price];
}
@end

View file

@ -1,33 +0,0 @@
//
// TroveboxPaymentTransactionObserver.h
// Trovebox
//
// Created by Patrick Santana on 08/02/13.
// Copyright 2013 Trovebox
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//for payment
#import <StoreKit/StoreKit.h>
#import "AuthenticationService.h"
#define kInAppPurchaseManagerTransactionFailedNotification @"kInAppPurchaseManagerTransactionFailedNotification"
#define kInAppPurchaseManagerTransactionSucceededNotification @"kInAppPurchaseManagerTransactionSucceededNotification"
#define kInAppPurchaseProUpgradeProductId @"SUBS_TROVEBOX_MONTH"
@interface TroveboxPaymentTransactionObserver : NSObject <SKPaymentTransactionObserver>
+ (TroveboxPaymentTransactionObserver*) troveboxPaymentTransactionObserver;
@end

View file

@ -1,190 +0,0 @@
//
// TroveboxPaymentTransactionObserver.m
// Trovebox
//
// Created by Patrick Santana on 08/02/13.
// Copyright 2013 Trovebox
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "TroveboxPaymentTransactionObserver.h"
@implementation TroveboxPaymentTransactionObserver
+ (TroveboxPaymentTransactionObserver*) troveboxPaymentTransactionObserver
{
static dispatch_once_t pred;
static TroveboxPaymentTransactionObserver *shared = nil;
dispatch_once(&pred, ^{
shared = [[TroveboxPaymentTransactionObserver alloc] init];
});
return shared;
}
//
// saves a record of the transaction by storing the receipt to disk
//
- (void)recordTransaction:(SKPaymentTransaction *)transaction
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"recordTransaction");
#endif
if ([transaction.payment.productIdentifier isEqualToString:kInAppPurchaseProUpgradeProductId])
{
// save the transaction receipt to disk
[[NSUserDefaults standardUserDefaults] setValue:transaction.transactionReceipt forKey:kProfileAccountProReceipt];
[[NSUserDefaults standardUserDefaults] synchronize];
// send the receipt to the
// do it in a queue
dispatch_queue_t send_receipt_server = dispatch_queue_create("send_receipt_server", NULL);
dispatch_async(send_receipt_server, ^{
@try{
[AuthenticationService sendToServerReceipt:transaction.transactionReceipt forUser:[SharedAppDelegate userEmail]];
}@catch (NSException* exception) {
NSLog(@"Error sending receipt to server %@", [exception description]);
}
});
}
}
//
// enable pro features
//
- (void)provideContent:(NSString *)productId
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"provideContent");
#endif
if ([productId isEqualToString:kInAppPurchaseProUpgradeProductId])
{
// enable the pro features after 3 seconds
[NSThread sleepForTimeInterval:3];
[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:nil userInfo:nil];
}
}
//
// removes the transaction from the queue and posts a notification with the transaction result
//
- (void)finishTransaction:(SKPaymentTransaction *)transaction wasSuccessful:(BOOL)wasSuccessful
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"finishTransaction");
#endif
// remove the transaction from the payment queue.
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:transaction, @"transaction" , nil];
if (wasSuccessful)
{
// send out a notification that weve finished the transaction
[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerTransactionSucceededNotification object:self userInfo:userInfo];
}
else
{
// send out a notification for the failed transaction
[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerTransactionFailedNotification object:self userInfo:userInfo];
}
}
//
// called when the transaction was successful
//
- (void)completeTransaction:(SKPaymentTransaction *)transaction
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"completeTransaction");
#endif
[self recordTransaction:transaction];
[self provideContent:transaction.payment.productIdentifier];
[self finishTransaction:transaction wasSuccessful:YES];
}
//
// called when a transaction has been restored and and successfully completed
//
- (void)restoreTransaction:(SKPaymentTransaction *)transaction
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"restoreTransaction");
#endif
[self recordTransaction:transaction.originalTransaction];
[self provideContent:transaction.originalTransaction.payment.productIdentifier];
[self finishTransaction:transaction wasSuccessful:YES];
}
//
// called when a transaction has failed
//
- (void)failedTransaction:(SKPaymentTransaction *)transaction
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"failedTransaction");
#endif
if (transaction.error.code != SKErrorPaymentCancelled)
{
// error!
[self finishTransaction:transaction wasSuccessful:NO];
}
else
{
// this is fine, the user just cancelled, so dont notify
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// send notification to remove the progress bar
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationProfileRemoveProgressBar object:nil userInfo:nil];
}
}
#pragma mark -
#pragma mark SKPaymentTransactionObserver methods
//
// called when the transaction status is updated
//
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"paymentQueue");
#endif
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
break;
default:
break;
}
}
}
@end

View file

@ -1,39 +0,0 @@
//
// TroveboxSubscription.h
// Trovebox
//
// Created by Patrick Santana on 20/02/13.
// Copyright 2013 Trovebox
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//for payment
#import <StoreKit/StoreKit.h>
#define kInAppPurchaseManagerProductsFetchedNotification @"kInAppPurchaseManagerProductsFetchedNotification"
@interface TroveboxSubscription : NSObject <SKProductsRequestDelegate>
{
SKProductsRequest *productsRequest;
}
@property (nonatomic, retain) SKProduct *proUpgradeProduct;
+ (TroveboxSubscription*) troveboxSubscription;
// init the details for the suscription
- (void) requestProUpgradeProductData;
- (SKProduct*) product;
@end

View file

@ -1,92 +0,0 @@
//
// TroveboxSubscription.m
// Trovebox
//
// Created by Patrick Santana on 20/02/13.
// Copyright 2013 Trovebox
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "TroveboxSubscription.h"
@implementation TroveboxSubscription
@synthesize proUpgradeProduct=_proUpgradeProduct;
+ (TroveboxSubscription*) troveboxSubscription
{
static dispatch_once_t pred;
static TroveboxSubscription *shared = nil;
dispatch_once(&pred, ^{
shared = [[TroveboxSubscription alloc] init];
});
return shared;
}
- (void) requestProUpgradeProductData
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"Init subscriptions details");
#endif
NSSet *productIdentifiers = [NSSet setWithObject:kInAppPurchaseProUpgradeProductId];
productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:
productIdentifiers];
productsRequest.delegate = self;
[productsRequest start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray *products = response.products;
self.proUpgradeProduct = [products count] == 1 ? [products lastObject] : nil;
#ifdef DEVELOPMENT_ENABLED
if (self.proUpgradeProduct)
{
NSLog(@"Product title: %@" , self.proUpgradeProduct.localizedTitle);
NSLog(@"Product description: %@" , self.proUpgradeProduct.localizedDescription);
NSLog(@"Product price: %@" , self.proUpgradeProduct.price);
NSLog(@"Product id: %@" , self.proUpgradeProduct.productIdentifier);
}
#endif
for (NSString *invalidProductId in response.invalidProductIdentifiers)
{
NSLog(@"Invalid product id: %@" , invalidProductId);
}
[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil];
}
- (SKProduct*) product{
return self.proUpgradeProduct;
}
-(void)requestDidFinish:(SKRequest *)request
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"Request did finish = %@",request);
#endif
}
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
#ifdef DEVELOPMENT_ENABLED
NSLog(@"Failed to connect with error: %@", [error localizedDescription]);
#endif
}
@end

View file

@ -136,7 +136,6 @@
CD30D84216369CF1001A0CA0 /* PhotoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD30D84016369CF1001A0CA0 /* PhotoViewController.xib */; };
CD30D8511636A98C001A0CA0 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD30D8501636A98C001A0CA0 /* Accelerate.framework */; };
CD30D8531636A9AB001A0CA0 /* libsqlite3.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD30D8521636A9AB001A0CA0 /* libsqlite3.0.dylib */; };
CD30D8551636A9C0001A0CA0 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD30D8541636A9BF001A0CA0 /* StoreKit.framework */; };
CD30D8571636A9CE001A0CA0 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD30D8561636A9CE001A0CA0 /* CoreText.framework */; };
CD30D8591636A9DB001A0CA0 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD30D8581636A9DA001A0CA0 /* OpenGLES.framework */; };
CD31DECE17143FFA0071D3E1 /* menu-album-selected.png in Resources */ = {isa = PBXBuildFile; fileRef = CD31DEC017143FF90071D3E1 /* menu-album-selected.png */; };
@ -338,9 +337,6 @@
CDCC0AF316E0C23700BE4481 /* sync-show@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CDCC0A7216E0C23700BE4481 /* sync-show@2x.png */; };
CDCC0B6416E0C49D00BE4481 /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCC0B5916E0C49D00BE4481 /* ProfileViewController.m */; };
CDCC0B6516E0C49D00BE4481 /* ProfileViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = CDCC0B5A16E0C49D00BE4481 /* ProfileViewController.xib */; };
CDCC0B6716E0C49D00BE4481 /* TroveboxPaymentTransactionObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCC0B5D16E0C49D00BE4481 /* TroveboxPaymentTransactionObserver.m */; };
CDCC0B6816E0C49D00BE4481 /* TroveboxSubscription.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCC0B5F16E0C49D00BE4481 /* TroveboxSubscription.m */; };
CDCC0B6916E0C49D00BE4481 /* SKProduct+LocalizedPrice.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCC0B6116E0C49D00BE4481 /* SKProduct+LocalizedPrice.m */; };
CDCC0B6A16E0C49D00BE4481 /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCC0B6316E0C49D00BE4481 /* WebViewController.m */; };
CDCC0BEE16E0C66400BE4481 /* AuthenticationViewController5.xib in Resources */ = {isa = PBXBuildFile; fileRef = CDCC0BB816E0C66400BE4481 /* AuthenticationViewController5.xib */; };
CDCC0BF016E0C66400BE4481 /* DateUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = CDCC0BBC16E0C66400BE4481 /* DateUtilities.m */; };
@ -963,7 +959,6 @@
CD30D84016369CF1001A0CA0 /* PhotoViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PhotoViewController.xib; sourceTree = "<group>"; };
CD30D8501636A98C001A0CA0 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
CD30D8521636A9AB001A0CA0 /* libsqlite3.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.0.dylib; path = usr/lib/libsqlite3.0.dylib; sourceTree = SDKROOT; };
CD30D8541636A9BF001A0CA0 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
CD30D8561636A9CE001A0CA0 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
CD30D8581636A9DA001A0CA0 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
CD31DEC017143FF90071D3E1 /* menu-album-selected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "menu-album-selected.png"; path = "images/menu-album-selected.png"; sourceTree = "<group>"; };
@ -1214,12 +1209,6 @@
CDCC0B5816E0C49D00BE4481 /* ProfileViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfileViewController.h; sourceTree = "<group>"; };
CDCC0B5916E0C49D00BE4481 /* ProfileViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProfileViewController.m; sourceTree = "<group>"; };
CDCC0B5A16E0C49D00BE4481 /* ProfileViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ProfileViewController.xib; sourceTree = "<group>"; };
CDCC0B5C16E0C49D00BE4481 /* TroveboxPaymentTransactionObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TroveboxPaymentTransactionObserver.h; sourceTree = "<group>"; };
CDCC0B5D16E0C49D00BE4481 /* TroveboxPaymentTransactionObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TroveboxPaymentTransactionObserver.m; sourceTree = "<group>"; };
CDCC0B5E16E0C49D00BE4481 /* TroveboxSubscription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TroveboxSubscription.h; sourceTree = "<group>"; };
CDCC0B5F16E0C49D00BE4481 /* TroveboxSubscription.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TroveboxSubscription.m; sourceTree = "<group>"; };
CDCC0B6016E0C49D00BE4481 /* SKProduct+LocalizedPrice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SKProduct+LocalizedPrice.h"; sourceTree = "<group>"; };
CDCC0B6116E0C49D00BE4481 /* SKProduct+LocalizedPrice.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SKProduct+LocalizedPrice.m"; sourceTree = "<group>"; };
CDCC0B6216E0C49D00BE4481 /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewController.h; sourceTree = "<group>"; };
CDCC0B6316E0C49D00BE4481 /* WebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewController.m; sourceTree = "<group>"; };
CDCC0BB816E0C66400BE4481 /* AuthenticationViewController5.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AuthenticationViewController5.xib; sourceTree = "<group>"; };
@ -1350,7 +1339,6 @@
CDF2F10416E52DDD00D309B9 /* Accounts.framework in Frameworks */,
CDF2F10216E52DCC00D309B9 /* AdSupport.framework in Frameworks */,
CDF2F06E16E4D87A00D309B9 /* MapKit.framework in Frameworks */,
CD30D8551636A9C0001A0CA0 /* StoreKit.framework in Frameworks */,
CD30D8571636A9CE001A0CA0 /* CoreText.framework in Frameworks */,
CD30D8531636A9AB001A0CA0 /* libsqlite3.0.dylib in Frameworks */,
CD30D8511636A98C001A0CA0 /* Accelerate.framework in Frameworks */,
@ -1769,14 +1757,6 @@
CDCC0B5916E0C49D00BE4481 /* ProfileViewController.m */,
CDCC0B5A16E0C49D00BE4481 /* ProfileViewController.xib */,
CD9013461726C66800BB30EF /* ProfileViewControlleriPad.xib */,
CDCC0B5C16E0C49D00BE4481 /* TroveboxPaymentTransactionObserver.h */,
CDCC0B5D16E0C49D00BE4481 /* TroveboxPaymentTransactionObserver.m */,
CDCC0B5E16E0C49D00BE4481 /* TroveboxSubscription.h */,
CDCC0B5F16E0C49D00BE4481 /* TroveboxSubscription.m */,
CDCC0B6016E0C49D00BE4481 /* SKProduct+LocalizedPrice.h */,
CDCC0B6116E0C49D00BE4481 /* SKProduct+LocalizedPrice.m */,
CDCC0B6216E0C49D00BE4481 /* WebViewController.h */,
CDCC0B6316E0C49D00BE4481 /* WebViewController.m */,
CDCC0BDD16E0C66400BE4481 /* Settings.bundle */,
);
name = Settings;
@ -2010,6 +1990,8 @@
CD7642B7161EDFCA00E0B657 /* Utility */ = {
isa = PBXGroup;
children = (
CDCC0B6216E0C49D00BE4481 /* WebViewController.h */,
CDCC0B6316E0C49D00BE4481 /* WebViewController.m */,
CDCC0BE816E0C66400BE4481 /* UpdateUtilities.h */,
CDCC0BE916E0C66400BE4481 /* UpdateUtilities.m */,
CDCC0BE616E0C66400BE4481 /* TransformationUtilities.h */,
@ -2153,7 +2135,6 @@
CD30D5F7163041A4001A0CA0 /* AssetsLibrary.framework */,
CD30D8581636A9DA001A0CA0 /* OpenGLES.framework */,
CD30D8561636A9CE001A0CA0 /* CoreText.framework */,
CD30D8541636A9BF001A0CA0 /* StoreKit.framework */,
CD30D8521636A9AB001A0CA0 /* libsqlite3.0.dylib */,
CD30D8501636A98C001A0CA0 /* Accelerate.framework */,
CD7642B1161EDB9E00E0B657 /* libz.dylib */,
@ -2329,6 +2310,11 @@
TargetAttributes = {
CDAFB9CD16122262002D6E86 = {
DevelopmentTeam = 7396XV45JF;
SystemCapabilities = {
com.apple.InAppPurchase = {
enabled = 0;
};
};
};
};
};
@ -3035,9 +3021,6 @@
CDC7AEDC163EDD3A00FC8BC1 /* PrivateAuthenticationService.m in Sources */,
CDC7AF2E1640156400FC8BC1 /* GalleryViewController.m in Sources */,
CDCC0B6416E0C49D00BE4481 /* ProfileViewController.m in Sources */,
CDCC0B6716E0C49D00BE4481 /* TroveboxPaymentTransactionObserver.m in Sources */,
CDCC0B6816E0C49D00BE4481 /* TroveboxSubscription.m in Sources */,
CDCC0B6916E0C49D00BE4481 /* SKProduct+LocalizedPrice.m in Sources */,
CDCF8650180371C2002E7A39 /* DACircularProgressView.m in Sources */,
CDCC0B6A16E0C49D00BE4481 /* WebViewController.m in Sources */,
CDCC0BF016E0C66400BE4481 /* DateUtilities.m in Sources */,