3
我如何检查应用程序购买而不进行实际payment.Do我必须上传在iTunes上建立检查应用程序购买。 我在iTunes中创建了产品ID,并且还使用了沙箱用户进行测试。 但我不知道如何继续下一步。在应用程序购买实施
我如何检查应用程序购买而不进行实际payment.Do我必须上传在iTunes上建立检查应用程序购买。 我在iTunes中创建了产品ID,并且还使用了沙箱用户进行测试。 但我不知道如何继续下一步。在应用程序购买实施
经过长时间的RnD,我找到了解决方案。 - 第一你必须在输入所有信息后,在itunes之前创建一个产品ID,在此之前,确保所有的银行,税务和账户信息填写协议。 - 你也必须采取屏幕截图的要求在应用程序购买。 - 后,使在应用程序购买的Xcode功能。 -Import框架 -Import IAPHelper和RageIAPHelper类到你的项目 - 在您的viewcontroller.h类 在IAPHelper.m
添加这些NSArray *_products;
NSNumberFormatter * _priceFormatter;
-(void)viewdidload
{
[self reload];
[[RageIAPHelper sharedInstance] restoreCompletedTransactions];
_priceFormatter = [[NSNumberFormatter alloc] init];
[_priceFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[_priceFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
}
- (void)restoreTapped:(id)sender {
[[RageIAPHelper sharedInstance] restoreCompletedTransactions];
}
- (void)productPurchased:(NSNotification *)notification {
NSString * productIdentifier = notification.object;
[_products enumerateObjectsUsingBlock:^(SKProduct * product, NSUInteger idx, BOOL *stop) {
if ([product.productIdentifier isEqualToString:productIdentifier]) {
*stop = YES;
NSLog(@" productPurchased");
}
- (void)reload {
_products = nil;
[[RageIAPHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
if (success) {
_products = products;
}
}];
}
- (void)buyButtonTapped {
SKProduct *product = _products[0];
NSLog(@"Buying %@...", product.productIdentifier);
if(product!=nil)
{
[[RageIAPHelper sharedInstance] buyProduct:product];
}
else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirm Your In-App Purchase"
message:@"Subscription is required to access thi sfeature."
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Buy", nil];
[alert show];
}
}
-(void)viewwillappear
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(productPurchased:) name:IAPHelperProductPurchasedNotification object:nil];
}
- (void)provideContentForProductIdentifier:(NSString *)productIdentifier {
if ([productIdentifier isEqualToString:@"com.abc.productName"]) {
int currentValue = [[NSUserDefaults standardUserDefaults] integerForKey:@"com.abc.productName"];
}
这里替换“com.abc .productName“与您创建的产品ID。 这是代码部分的所有内容 要测试应用程序购买 - 登出电话设置中的现有Apple ID并使用您从itunes创建的沙箱用户登录。 然后你可以检查它没有实际的付款。
要下载IAPHelper类和文档参考:https://github.com/saturngod/IAPHelper