forked from mirrors/linphone-iphone
work in progress with inapps
This commit is contained in:
parent
6cb3a41187
commit
6ca2279bf8
9 changed files with 90 additions and 23 deletions
|
|
@ -7,9 +7,13 @@
|
|||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ShopView">
|
||||
<connections>
|
||||
<outlet property="accountBuyButton" destination="0bU-UW-3nR" id="GOQ-1M-4kI"/>
|
||||
<outlet property="accountProductDescription" destination="Ubj-Hn-QQP" id="itS-zY-QnV"/>
|
||||
<outlet property="accountProductPrice" destination="Hhk-KZ-LpO" id="rao-hi-s4Y"/>
|
||||
<outlet property="accountProductTitle" destination="8CD-Y8-Ad3" id="29E-MO-OgE"/>
|
||||
<outlet property="landscapeView" destination="sVO-4a-t1s" id="9ye-NV-onQ"/>
|
||||
<outlet property="portraitView" destination="HJH-1o-RXN" id="Hoa-uk-q9s"/>
|
||||
<outlet property="view" destination="HJH-1o-RXN" id="t5Y-ob-1WC"/>
|
||||
<outlet property="view" destination="HJH-1o-RXN" id="OKD-FI-yhX"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
|
|
@ -56,24 +60,31 @@
|
|||
<rect key="frame" x="0.0" y="66" width="375" height="535"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Product description" lineBreakMode="wordWrap" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Ubj-Hn-QQP" userLabel="productDescription">
|
||||
<rect key="frame" x="16" y="35" width="209" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="0bU-UW-3nR" userLabel="purchaseButton">
|
||||
<rect key="frame" x="283" y="32" width="72" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" title="Purchase"/>
|
||||
<rect key="frame" x="303" y="31" width="72" height="30"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<state key="normal" title="Buy"/>
|
||||
<connections>
|
||||
<action selector="onPurchaseButtonClick:" destination="-1" eventType="touchUpInside" id="ZX7-nC-4Mi"/>
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0.5 €" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Hhk-KZ-LpO">
|
||||
<rect key="frame" x="225" y="36" width="42" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Product title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" highlighted="YES" adjustsFontSizeToFit="NO" id="8CD-Y8-Ad3" userLabel="productTitle">
|
||||
<rect key="frame" x="16" y="11" width="289" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="12 months service" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Ubj-Hn-QQP" userLabel="goodTitle">
|
||||
<rect key="frame" x="16" y="22" width="179" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0.5 €" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Hhk-KZ-LpO">
|
||||
<rect key="frame" x="258" y="35" width="55" height="21"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ typedef NSString *IAPPurchaseNotificationStatus;
|
|||
andEmail:(NSString *)email
|
||||
monthly:(BOOL)monthly;
|
||||
// Purchase a product. You should not use this if manager is not available yet.
|
||||
- (BOOL)purchaseWitID:(NSString *)productID;
|
||||
- (BOOL)purchaseWithID:(NSString *)productID;
|
||||
// Activate purchased account.
|
||||
- (BOOL)activateAccount:(NSString *)phoneNumber;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
@implementation InAppProductsManager
|
||||
|
||||
// LINPHONE_CAPABILITY_INAPP_PURCHASE must be defined in Linphone Build Settings
|
||||
#if LINPHONE_CAPABILITY_INAPP_PURCHASE && !TARGET_IPHONE_SIMULATOR
|
||||
#if 1
|
||||
|
||||
- (instancetype)init {
|
||||
if ((self = [super init]) != nil) {
|
||||
|
|
@ -76,7 +76,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
- (BOOL)purchaseWitID:(NSString *)productID {
|
||||
- (BOOL)purchaseWithID:(NSString *)productID {
|
||||
if (!_enabled || !_initialized || !_available) {
|
||||
NSDictionary *dict = @{
|
||||
@"product_id" : productID,
|
||||
|
|
@ -111,7 +111,7 @@
|
|||
inSection:@"in_app_purchase"];
|
||||
self.accountCreationData = @{ @"phoneNumber" : phoneNumber, @"password" : password, @"email" : email };
|
||||
|
||||
if (![self purchaseWitID:productID]) {
|
||||
if (![self purchaseWithID:productID]) {
|
||||
self.accountCreationData = nil;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -497,7 +497,7 @@
|
|||
[self postNotificationforStatus:kIAPRestoreFailed];
|
||||
return false;
|
||||
}
|
||||
- (BOOL)purchaseWitID:(NSString *)productID {
|
||||
- (BOOL)purchaseWithID:(NSString *)productID {
|
||||
[self postNotificationforStatus:kIAPPurchaseFailed];
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
23
Classes/RenewalManager.h
Normal file
23
Classes/RenewalManager.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// RenewalManager.h
|
||||
// linphone
|
||||
//
|
||||
// Created by Simon Morlat on 11/08/2016.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef RenewalManager_h
|
||||
#define RenewalManager_h
|
||||
|
||||
|
||||
@interface RenewalManager : NSObject {
|
||||
@protected
|
||||
|
||||
@private
|
||||
|
||||
@public
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif /* RenewalManager_h */
|
||||
|
|
@ -23,6 +23,11 @@
|
|||
|
||||
@interface ShopView : TPMultiLayoutViewController <UICompositeViewDelegate>
|
||||
|
||||
@property(weak, nonatomic) IBOutlet UILabel *accountProductTitle;
|
||||
@property(weak, nonatomic) IBOutlet UILabel *accountProductDescription;
|
||||
@property(weak, nonatomic) IBOutlet UILabel *accountProductPrice;
|
||||
@property(weak, nonatomic) IBOutlet UIButton *accountBuyButton;
|
||||
|
||||
- (IBAction)onLinkTap:(id)sender;
|
||||
- (IBAction)onDialerBackClick:(id)sender;
|
||||
- (IBAction)onPurchaseButtonClick:(id)sender;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,20 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
#pragma mark - ViewController Functions
|
||||
|
||||
- (void)viewDidLoad {
|
||||
InAppProductsManager *aipm = LinphoneManager.instance.iapManager;
|
||||
NSMutableArray *productsAvailable = aipm.productsAvailable;
|
||||
if ( [productsAvailable count] > 0){
|
||||
SKProduct *product = [productsAvailable objectAtIndex:0];
|
||||
[_accountProductTitle setText:product.localizedTitle];
|
||||
[_accountProductDescription setText:product.localizedDescription];
|
||||
|
||||
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
|
||||
[numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
|
||||
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
|
||||
[numberFormatter setLocale:product.priceLocale];
|
||||
NSString *formattedString = [numberFormatter stringFromNumber:product.price];
|
||||
[_accountProductPrice setText:formattedString];
|
||||
}
|
||||
[super viewDidLoad];
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#import "PhoneMainView.h"
|
||||
#import "StatusBarView.h"
|
||||
#import "ShopView.h"
|
||||
#import "LinphoneManager.h"
|
||||
|
||||
@implementation SideMenuEntry
|
||||
|
||||
|
|
@ -48,12 +49,14 @@
|
|||
[PhoneMainView.instance
|
||||
changeCurrentView:SettingsView.compositeViewDescription];
|
||||
}]];
|
||||
[_sideMenuEntries addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Shop", nil)
|
||||
InAppProductsManager *iapm = LinphoneManager.instance.iapManager;
|
||||
if (iapm.enabled){
|
||||
[_sideMenuEntries addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Shop", nil)
|
||||
tapBlock:^() {
|
||||
[PhoneMainView.instance
|
||||
changeCurrentView:ShopView.compositeViewDescription];
|
||||
|
||||
}]];
|
||||
}
|
||||
[_sideMenuEntries addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"About", nil)
|
||||
tapBlock:^() {
|
||||
[PhoneMainView.instance
|
||||
|
|
|
|||
|
|
@ -28,4 +28,10 @@ eq_location=mic
|
|||
ringer_dev_id=AQ: Audio Queue Device
|
||||
|
||||
[video]
|
||||
display_filter_auto_rotate=0
|
||||
display_filter_auto_rotate=0
|
||||
|
||||
[in_app_purchase]
|
||||
enabled=1
|
||||
paid_account_id=sipAccount_12m
|
||||
receipt_validation_url=https://www.linphone.org/inapp.php
|
||||
products_list=sipAccount_12m
|
||||
|
|
@ -42,6 +42,7 @@
|
|||
344ABDF214850AE9007420B6 /* libstdc++.6.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 344ABDF014850AE9007420B6 /* libstdc++.6.dylib */; settings = {ATTRIBUTES = (Weak, ); }; };
|
||||
570742581D5A0691004B9C84 /* ShopView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 570742561D5A0691004B9C84 /* ShopView.xib */; };
|
||||
570742611D5A09B8004B9C84 /* ShopView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5707425F1D5A09B8004B9C84 /* ShopView.m */; };
|
||||
570742671D5A63DB004B9C84 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 570742661D5A63DB004B9C84 /* StoreKit.framework */; };
|
||||
630589E71B4E810900EFAE36 /* ChatTester.m in Sources */ = {isa = PBXBuildFile; fileRef = 630589DF1B4E810900EFAE36 /* ChatTester.m */; };
|
||||
630589E81B4E810900EFAE36 /* ContactsTester.m in Sources */ = {isa = PBXBuildFile; fileRef = 630589E11B4E810900EFAE36 /* ContactsTester.m */; };
|
||||
630589EA1B4E810900EFAE36 /* LinphoneTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 630589E41B4E810900EFAE36 /* LinphoneTestCase.m */; };
|
||||
|
|
@ -941,6 +942,8 @@
|
|||
570742601D5A09B8004B9C84 /* ShopView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShopView.h; sourceTree = "<group>"; };
|
||||
570742631D5A1860004B9C84 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/ShopView.strings; sourceTree = "<group>"; };
|
||||
570742651D5A1868004B9C84 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/ShopView.strings; sourceTree = "<group>"; };
|
||||
570742661D5A63DB004B9C84 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
|
||||
570742681D5C852B004B9C84 /* RenewalManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenewalManager.h; sourceTree = "<group>"; };
|
||||
630589DE1B4E810900EFAE36 /* ChatTester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatTester.h; sourceTree = "<group>"; };
|
||||
630589DF1B4E810900EFAE36 /* ChatTester.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatTester.m; sourceTree = "<group>"; };
|
||||
630589E01B4E810900EFAE36 /* ContactsTester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactsTester.h; sourceTree = "<group>"; };
|
||||
|
|
@ -1821,6 +1824,7 @@
|
|||
63CFEE0A1B9EDD88007EA5BD /* libmssilk.a in Frameworks */,
|
||||
63CFEE0B1B9EDD88007EA5BD /* libmswebrtc.a in Frameworks */,
|
||||
63CFEE0C1B9EDD88007EA5BD /* libmsx264.a in Frameworks */,
|
||||
570742671D5A63DB004B9C84 /* StoreKit.framework in Frameworks */,
|
||||
63CFEDF61B9EDD74007EA5BD /* libopencore-amrnb.a in Frameworks */,
|
||||
63CFEDF71B9EDD74007EA5BD /* libopencore-amrwb.a in Frameworks */,
|
||||
63CFEDF81B9EDD74007EA5BD /* libopenh264.a in Frameworks */,
|
||||
|
|
@ -2049,6 +2053,7 @@
|
|||
D326483415887D4400930C67 /* Utils */,
|
||||
34216F3E1547EBCD00EA9777 /* VideoZoomHandler.h */,
|
||||
34216F3F1547EBCD00EA9777 /* VideoZoomHandler.m */,
|
||||
570742681D5C852B004B9C84 /* RenewalManager.h */,
|
||||
);
|
||||
path = Classes;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -2181,6 +2186,7 @@
|
|||
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
570742661D5A63DB004B9C84 /* StoreKit.framework */,
|
||||
636920661D253DF700D44CAC /* libbcunit.a */,
|
||||
637835A41CFD971D00599382 /* libbv16.a */,
|
||||
63FD3F061CA17F9100E9AECC /* libmbedcrypto.a */,
|
||||
|
|
@ -3116,7 +3122,10 @@
|
|||
DevelopmentTeam = Z2V957B3D6;
|
||||
SystemCapabilities = {
|
||||
com.apple.InAppPurchase = {
|
||||
enabled = 0;
|
||||
enabled = 1;
|
||||
};
|
||||
com.apple.Push = {
|
||||
enabled = 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -4467,7 +4476,6 @@
|
|||
"-Werror=objc-method-access",
|
||||
"-Werror=incomplete-implementation",
|
||||
"-Wno-error-deprecated",
|
||||
"-DLINPHONE_CAPABILITY_INAPP_PURCHASE=0",
|
||||
);
|
||||
};
|
||||
name = Debug;
|
||||
|
|
@ -4555,7 +4563,6 @@
|
|||
"-Werror=objc-method-access",
|
||||
"-Werror=incomplete-implementation",
|
||||
"-Wno-error-deprecated",
|
||||
"-DLINPHONE_CAPABILITY_INAPP_PURCHASE=0",
|
||||
);
|
||||
};
|
||||
name = DistributionAdhoc;
|
||||
|
|
@ -4642,7 +4649,6 @@
|
|||
"-Werror=objc-method-access",
|
||||
"-Werror=incomplete-implementation",
|
||||
"-Wno-error-deprecated",
|
||||
"-DLINPHONE_CAPABILITY_INAPP_PURCHASE=0",
|
||||
);
|
||||
};
|
||||
name = Release;
|
||||
|
|
@ -4730,7 +4736,6 @@
|
|||
"-Werror=objc-method-access",
|
||||
"-Werror=incomplete-implementation",
|
||||
"-Wno-error-deprecated",
|
||||
"-DLINPHONE_CAPABILITY_INAPP_PURCHASE=0",
|
||||
);
|
||||
};
|
||||
name = Distribution;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue