2012-12-06 3 views
0

인앱 구매 제품이 인터넷 연결없이 요청 된 경우를 처리하고 싶습니다. SKProductRequest가 연결없이 실패하지 않습니다.

시뮬레이터와 (와이파이를 해제하여) 디바이스 모두 이때 테스트 대신 request:didFailWithError:에 호출을 수신하는 I은 requestDidFinish:에이어서 빈 제품 어레이 호 productsRequest:didReceiveResponse: 및 수신한다.

이것은 예상되는 동작입니까? 그렇다면 요청이 연결 문제로 인해 실패했는지 어떻게 알 수 있습니까? 그렇지 않다면 무엇이 잘못되었을 수 있습니까? 그 예상되는 동작 워드 프로세서가 조금 있기 때문에 경우 나도 몰라 내가 아이폰 OS 6

답변

1

을 사용하고

- (void) requestProducts:(NSSet*)identifiers 
{ 
    _productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers]; 
    _productsRequest.delegate = self; 
    [_productsRequest start]; 
} 

:이 도움이 경우

이 나는 ​​제품을 요청하는 방법입니다 피사체에 드문 드문. 그러나 나는 항상 CheckIt을 직접 수행하므로 StoreKit 오류가 매우 정교하지 않은 것으로 보이는 절반의 시간이 걸리기 때문에 사용자에게 좋은 오류 메시지를 제공 할 수 있습니다. 최근 프로젝트에서 사용한 코드는 다음과 같습니다.

나는 자신의 storeManager 대리인이 전화 및 상속을 단순화하기 위해 작성되었지만 상황이 아주 분명해야합니다.

#pragma mark - Purchase Methods 

- (void)purchaseProduct:(SKProduct *)product 
{ 
    // Check Internet 
    if ([self checkInternetConnectionAndAlertUser:YES]) { 

     // Check Restrictions 
     if ([self checkRestrictionsAndAlertUser:YES]) { 

      // Check Products 
      if ([_products containsObject:product]) { 

       // Purchase the product 
       [[SKPaymentQueue defaultQueue] addPayment:[SKPayment paymentWithProduct:product]]; 

      } else { 
       [[[UIAlertView alloc] initWithTitle:@"Error" message:@"Sorry, we couldn't find that product." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; 
       [self.delegate purchaseDidFailWithError:[NSError errorWithDomain:@"SDInAppPurchaseManager" code:404 userInfo:@{ NSLocalizedDescriptionKey : @"Product not found." }]]; 
      } 
     } else { 
      // Not allowed to make purchase 
      [self.delegate requestdidFailWithError:[NSError errorWithDomain:@"SDInAppPurchaseManager" code:500 userInfo:@{ NSLocalizedDescriptionKey : @"Not authorized to make purchases." }]]; 
     } 
    } else { 
     // No Internet 
     [self.delegate requestdidFailWithError:[NSError errorWithDomain:@"SDInAppPurchaseManager" code:300 userInfo:@{ NSLocalizedDescriptionKey : @"No internet connection." }]]; 
    } 
} 
#pragma mark - Checks 

- (BOOL)checkInternetConnectionAndAlertUser:(BOOL)alert 
{ 
    if ([[SDDataManager dataManager] internetConnection]) { 
     return YES; 
    } else { 
     // Alert the user if necessary. 
     if (alert) { 
      [[[UIAlertView alloc] initWithTitle:@"No Connection" message:@"You don't appear to be connected to the internet. Please check your connection and try again." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; 
     } 

     return NO; 
    } 
} 

- (BOOL)checkRestrictionsAndAlertUser:(BOOL)alert 
{ 
    if ([SKPaymentQueue canMakePayments]) { 
     return YES; 
    } else { 
     // Alert the user if necessary. 
     if (alert) { 
      [[[UIAlertView alloc] initWithTitle:@"Purchases Disabled" message:@"In App Purchasing is disabled for your device or account. Please check your settings and try again." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show]; 
     } 

     return NO; 
    } 
} 
관련 문제