获取无效的产品ID(应用内购买)

时间:2015-07-21 06:46:13

标签: ios in-app-purchase storekit

我正在使用此方法验证我的产品: - 为了获得产品数组,我首先解析从服务器下载的XML文件, 并获得产品列表,但ID始终无效。

- (void) validateProductsIdentifiers:(NSArray *) products {

NSMutableArray *productsIds = [[NSMutableArray alloc] init];

if (products != nil) {

    for (EJBookInStore * book in products) {
        //for each book, save the book id
        [productsIds addObject:[book idBook]];
    }
    //Verify if the array is not empty
    if ([productsIds count] > 0) {

        SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:productsIds]];
        productsRequest.delegate = self;
        [productsRequest start];
    }
} else {

    NSLog(@"Erro...");
}

当我直接在方法中输入id时,id为validate:

   - (void) validateProductsIdentifiers:(NSArray *) products {

    NSMutableArray *productsIds = [[NSMutableArray alloc] init];

    if (products != nil) {

         for (EJBookInStore * book in products) {
            //for each book, save the book id
            [productsIds addObject:[book idBook]];
        }
        //Verify if the array is not empty
        if ([productsIds count] > 0) {
            //When i set the id like this, the id is validated
            NSArray *prodIds = [NSArray arrayWithObjects:@"com.example.bookA", nil];
            SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray: prodIds]];
            productsRequest.delegate = self;
            [productsRequest start];
        }
    } else {

        NSLog(@"Error...");
    }
}

0 个答案:

没有答案