mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
continue
This commit is contained in:
parent
5c02755992
commit
d241652f6b
7 changed files with 25 additions and 19 deletions
|
|
@ -7,7 +7,7 @@
|
|||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <StoreKit/StoreKit.h>
|
||||
|
||||
@interface InAppProductsCell : UITableViewCell {
|
||||
}
|
||||
|
|
@ -22,4 +22,6 @@
|
|||
|
||||
+ (CGFloat)getHeight:(BOOL)maximized;
|
||||
|
||||
- (void)fillFromProduct:(SKProduct*)prod;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -23,6 +23,17 @@
|
|||
[InAppProductsCell getHeight:isMaximized]);
|
||||
}
|
||||
|
||||
- (void)fillFromProduct:(SKProduct *)prod {
|
||||
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
|
||||
[formatter setLocale:prod.priceLocale];
|
||||
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
|
||||
NSString * formattedPrice = [formatter stringFromNumber:prod.price];
|
||||
|
||||
[_ptitle setText: [prod localizedTitle]];
|
||||
[_pdescription setText: [prod localizedDescription]];
|
||||
[_pprice setText: formattedPrice];
|
||||
[_ppurchased setOn: [[[LinphoneManager instance] iapManager] isPurchased:prod]];
|
||||
}
|
||||
- (id)initWithIdentifier:(NSString*)identifier maximized:(bool)maximized {
|
||||
if ((self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]) != nil) {
|
||||
NSArray *arrayOfViews = [[NSBundle mainBundle] loadNibNamed:@"InAppProductsCell"
|
||||
|
|
|
|||
|
|
@ -24,12 +24,10 @@
|
|||
NSString *const kLinphoneIAPurchaseNotification = @"LinphoneIAProductsNotification";
|
||||
|
||||
@implementation InAppProductsManager {
|
||||
bool ready;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
if ((self = [super init]) != nil) {
|
||||
ready = false;
|
||||
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
|
||||
[self loadProducts];
|
||||
}
|
||||
|
|
@ -40,8 +38,8 @@ NSString *const kLinphoneIAPurchaseNotification = @"LinphoneIAProductsNotificati
|
|||
if (! [SKPaymentQueue canMakePayments]) {
|
||||
return;
|
||||
}
|
||||
//TODO: move this list elsewhere
|
||||
NSArray * list = [[[NSArray alloc] initWithArray:@[@"test.auto_renew_7days", @"test.non_renew", @"test.one_time", @"test.auto_renew_1month_withfree"]] autorelease];
|
||||
NSArray * list = [[[[LinphoneManager instance] lpConfigStringForKey:@"inapp_products_list"] stringByReplacingOccurrencesOfString:@" " withString:@""] componentsSeparatedByString:@","];
|
||||
|
||||
_productsIDPurchased = [[NSMutableArray alloc] initWithCapacity:0];
|
||||
|
||||
SKProductsRequest *productsRequest = [[SKProductsRequest alloc]
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@
|
|||
#import "DTAlertView.h"
|
||||
|
||||
@implementation InAppProductsTableViewController {
|
||||
InAppProductsManager *iapm;
|
||||
NSInteger currentExpanded;
|
||||
InAppProductsManager *iapm;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
iapm = [[LinphoneManager instance] iapManager];
|
||||
currentExpanded = -1;
|
||||
iapm = [[LinphoneManager instance] iapManager];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(onIAPPurchaseNotification:)
|
||||
|
|
@ -35,6 +35,7 @@
|
|||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||
name:kLinphoneIAPurchaseNotification
|
||||
object:nil];
|
||||
|
||||
}
|
||||
|
||||
- (void)onIAPPurchaseNotification:(NSNotification*)notif {
|
||||
|
|
@ -62,14 +63,8 @@
|
|||
cell = [[[InAppProductsCell alloc] initWithIdentifier:kCellId maximized:(currentExpanded == indexPath.row)] autorelease];
|
||||
}
|
||||
SKProduct *prod = [[[[LinphoneManager instance] iapManager] productsAvailable] objectAtIndex:indexPath.row];
|
||||
[cell.ptitle setText: [prod localizedTitle]];
|
||||
[cell.pdescription setText: [prod localizedDescription]];
|
||||
[cell.pprice setText: [NSString stringWithFormat:@"%@", [prod price]]];
|
||||
[cell.ppurchased setOn: [iapm isPurchased:prod]];
|
||||
[cell fillFromProduct:prod];
|
||||
cell.isMaximized = (currentExpanded == indexPath.row);
|
||||
cell.productID = prod.productIdentifier;
|
||||
|
||||
LOGI(@"One more: %@", cell);
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -271,8 +271,6 @@ struct codec_name_pref_table codec_pref_table[]={
|
|||
LOGE(@"cannot register route change handler [%ld]",lStatus);
|
||||
}
|
||||
|
||||
_iapManager = [[InAppProductsManager alloc] init];
|
||||
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"msg" ofType:@"wav"];
|
||||
self.messagePlayer = [[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL URLWithString:path] error:nil] autorelease];
|
||||
|
||||
|
|
@ -300,6 +298,7 @@ struct codec_name_pref_table codec_pref_table[]={
|
|||
[self lpConfigSetBool:FALSE forKey:@"debugenable_preference"];
|
||||
#endif
|
||||
}
|
||||
_iapManager = [[InAppProductsManager alloc] init];
|
||||
|
||||
[self migrateFromUserPrefs];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,4 +54,5 @@ display_filter_auto_rotate=0
|
|||
[app]
|
||||
#contact_display_username_only=1
|
||||
#contact_filter_on_default_domain=1
|
||||
inapp_receipt_validation_url=https://linphone.org/inapp/veriyReceipt
|
||||
inapp_receipt_validation_url = https://linphone.org/inapp/veriyReceipt
|
||||
inapp_products_list = test.auto_renew_7days, test.non_renew, test.one_time, test.auto_renew_1month_withfree
|
||||
|
|
|
|||
|
|
@ -52,5 +52,5 @@ stun=stun.linphone.org
|
|||
display_filter_auto_rotate=0
|
||||
|
||||
[app]
|
||||
inapp_receipt_validation_url=https://linphone.org/inapp/veriyReceipt
|
||||
|
||||
inapp_receipt_validation_url = https://linphone.org/inapp/veriyReceipt
|
||||
inapp_products_list = test.auto_renew_7days, test.non_renew, test.one_time, test.auto_renew_1month_withfree
|
||||
Loading…
Add table
Reference in a new issue