2012-07-18 1 views
1

앱에서 인앱 구매를 구현했지만 제품을 요청할 때 몇 가지 문제가 있습니다. 상점에서 반환 된 제품의 순서가 내 식별자 목록의 순서와 일치하지 않습니다.SKProductsRequest를 사용하여 앱을 구매할 때 잘못된 주문이 있습니다.

self.request = [[[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObjects: @"50Hints",@"120Hints",@"250Hints",@"400Hints", nil]] autorelease]; 
    //NSLog(@"Sending request..."); 
    request.delegate = self; 
    [request start]; 

내가 같은 제품의 목록을 수신하고 있습니다 : 나는 다음과 같은 코드로 제품을 요청하고 같은 순서가 아닌

the products (
    "<SKProduct: 0xc660bb0>", 
    "<SKProduct: 0xc661110>", 
    "<SKProduct: 0xc661160>", 
    "<SKProduct: 0xc6611b0>" 
) 

(첫 번째는 "@에 해당 120Hints "대신에 @"50Hints ")

IOS 5 이전에는 문제가 없었습니다. [SKPayment paymentWithProductIdentifier : productIdentifier]를 사용할 수 있었기 때문에 productIdentifier는 제품 이름에 해당하는 문자열이지만 이제 사용해야합니다. 지불 ith 제품을 수락하는 제품 (예 : SKProduct : 0xc660bb0) 및 이름이 아닙니다. 그래서 나는 어느 것을 발견해야합니다.

paymentWithProduct를 사용하여 이름을 사용하여 제품을 구입할 수있는 방법이 있습니까? 그렇지 않은 경우 인앱 구매의 순서가 임의로 변경되거나 영구적입니까?

건배들 시릴

답변

0
내가 이런 짓을 한 방법은 사용자가 선택할 수있는 나는 테이블에 표시 일부의 SKProduct의 속성을 사용하는 것입니다

- 열 중 하나가있다 제품 식별자가 표시됩니다. 이것은 OSX 프로젝트에서 수행되었지만 개념은 동일해야합니다.

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { 
    self.productsFromItunes = [NSMutableArray array]; 
    for(SKProduct *aProduct in response.products){ 
     NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:aProduct,@"theProduct",aProduct.price,@"thePrice",aProduct.localizedTitle,@"theTitle",aProduct.productIdentifier,@"theID",nil]; 
     [self.productsFromItunes addObject:dict]; 
    } 
    [NSBundle loadNibNamed:@"BuyCredits" owner:self]; 
    [self.buyCreditsWindow makeKeyAndOrderFront:self];// this window has the table of choices 
} 

// Connected to the "Purchase" and "Cancel" buttons in the Buy Credits window 
-(IBAction)buyOrCancel:(NSButton *)sender { 
    if ([sender.title isEqualToString:@"Purchase"]){ 
     SKProduct *chosenProduct = [self.buyCreditsController.selectedObjects.lastObject valueForKey:@"theProduct"]; 
     SKPayment *thePayment = [SKPayment paymentWithProduct:chosenProduct]; 
     [SKPaymentQueue.defaultQueue addPayment:thePayment]; // This method sends the buy request to the app store 
    } 
    [self.buyCreditsWindow orderOut:self]; 
} 
+0

Perfect. 감사 –

관련 문제