未找到产品 - 在应用内购买(沙盒)

时间:2017-02-06 07:26:31

标签: ios objective-c in-app-purchase

我已经完成了应用程序购买的所有过程,但我得到了响应的空数组。

我已按照步骤操作 1.在developer.apple.com中创建了AppId和配置文件 2.在我的itunesconnect.apple.com中创建了新的应用程序,并添加了产品ID  在我的viewcontroller.m文件中

- (void)viewDidLoad
{
    [super viewDidLoad];

    if ([SKPaymentQueue canMakePayments]) {
      SKProductsRequest *_request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.hexa.InAppPurchaseDemo1.product4"]];
        _request.delegate = self;

        [_request start];
    } 
    else 
    {
        [[[UIAlertView alloc] initWithTitle:@"Serpentine" message:@"Error: Could not connect to store. Try enabling in-app-purchases in settings." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];

    }
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
    NSArray *products = response.products; // got empty array

    if (products.count != 0) 
    {
        _product = products[0];
    }
    else
    {
        [[[UIAlertView alloc] initWithTitle:@"Serpentine" message:@"Error: Could not connect to store" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];//this line of code runs a second after the controller opens
    }

    products = response.invalidProductIdentifiers;

    for (SKProduct *product in products) {
        NSLog(@"Product not found: %@", product);
    }
}

0 个答案:

没有答案
相关问题