Fixes #20 - Also removed deprecated PhoneGapCommand, using PGPlugin (new in 0.9.6)

This commit is contained in:
Shazron Abdullah
2011-06-27 22:34:29 -07:00
parent 5583f446ce
commit add22cb2d9
3 changed files with 27 additions and 3 deletions

View File

@@ -10,9 +10,9 @@
#import <StoreKit/StoreKit.h>
#ifdef PHONEGAP_FRAMEWORK
#import <PhoneGap/PhoneGapCommand.h>
#import <PhoneGap/PGPlugin.h>
#else
#import "PhoneGapCommand.h"
#import "PGPlugin.h"
#endif
#ifdef PHONEGAP_FRAMEWORK
@@ -23,7 +23,7 @@
#import "SKProduct+LocalizedPrice.h"
@interface InAppPurchaseManager : PhoneGapCommand <SKPaymentTransactionObserver> {
@interface InAppPurchaseManager : PGPlugin <SKPaymentTransactionObserver> {
}
- (void) setup:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

View File

@@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>
@interface SKProduct (LocalizedPrice)
@property (nonatomic, readonly) NSString *localizedPrice;
@end

View File

@@ -0,0 +1,16 @@
#import "SKProduct+LocalizedPrice.h"
@implementation SKProduct (LocalizedPrice)
- (NSString *)localizedPrice
{
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[numberFormatter setLocale:self.priceLocale];
NSString *formattedString = [numberFormatter stringFromNumber:self.price];
[numberFormatter release];
return formattedString;
}
@end