Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 应用内购买实施_Ios_In App Purchase_App Store_Itunes Store - Fatal编程技术网

Ios 应用内购买实施

Ios 应用内购买实施,ios,in-app-purchase,app-store,itunes-store,Ios,In App Purchase,App Store,Itunes Store,我如何在不支付实际费用的情况下检查应用内购买。我是否必须在iTunes上上传构建以检查应用内购买。 我在iTunes中创建了产品Id,还创建了一个沙盒用户进行测试。 但是我不知道下一步该怎么做。经过长时间的研究,我找到了解决办法。 -首先在输入所有信息后,您必须在itunes中创建一个产品Id,在此之前,请确保所有银行、税务和账户信息都已填写在协议中。 -您还必须拍摄请求应用内购买的屏幕截图。 -在之后,在xcode功能中启用应用内购买。 -导入框架 -将IAPHelper和RageIAPHel

我如何在不支付实际费用的情况下检查应用内购买。我是否必须在iTunes上上传构建以检查应用内购买。 我在iTunes中创建了产品Id,还创建了一个沙盒用户进行测试。
但是我不知道下一步该怎么做。

经过长时间的研究,我找到了解决办法。 -首先在输入所有信息后,您必须在itunes中创建一个产品Id,在此之前,请确保所有银行、税务和账户信息都已填写在协议中。 -您还必须拍摄请求应用内购买的屏幕截图。 -在之后,在xcode功能中启用应用内购买。 -导入框架 -将IAPHelper和RageIAPHelper类导入到项目中 -在viewcontroller.h类中 加上这些

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];
}
在IAPHelper.m

- (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类并获取文档,请参阅: