When updatedTransactions get called?

  1. when purchase is getting processed in the app.
  2. when there was updates on transaction including auto-renewal, offer-code
    1. Even though I want it’s not get called on auto-renewal case, when it was process successfully on server. There’s no way for the server to finish transaction like a client.
  3. when requested restoration.

Add Offer Code feature

https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/implementing_offer_codes_in_your_app

Even though it says “When the app is first launched, validate the receipt.” for the new users, you don’t need to. Because “updatedTransactions” gets called for this case too.

But it’s possible for a user to redeem code and then install the app after the purchase got expired. So I added a procedure to check whether the transaction is expired before alerting the user to sign up or sign in. You need to validate receipt to apple server to know expiration. It takes a while.

IAP 테스트

  1. 오퍼코드는 샌드박스로 테스트할 수가 없다. 테스트하려면 앱스토어에 올려진 앱으로 해야 함
  2. xcode로 올린 상태나 테스트 플라이트, 아니면 Ad hoc으로 뽑은 상태에서도 Sandbox로 테스트할 수 있다. 샌드박스에서는 기존 애플 아이디를 쓸 수도 있고,
    1. https://appstoreconnect.apple.com/access/testers에서 테스터를 추가해서 쓸 수 있다.
    2. 한 번 결제하면, 서버에서 아예 기록을 지워줘야 다시 결제해 볼 수 있다.
    3. 결제할 때 App Store가 아닌 Sandbox라고 뜬다.
    4. Sandbox 계정은 설정> 앱스토어에서 최하단에서 로그아웃할 수 있다.
  1. Xcode 12부터 새로운 IAP 테스트 방법이 나왔다.
    1. IAP용 configuration을 project에 추가하고
    2. Scheme 설정에서 StoreKit Configuration을 설정해주면 됨
    SKProductsRequest *productsRequest = [[SKPr
oductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:@"com.tall.monthly.promoted"]];
    productsRequest.delegate = self;
    [productsRequest start];
    return;

3. 제품 구매 시도할 때 productIdentifier를 configuration 파일에 있는 것과 똑같게 넣고,

4. 앱을 run해서 구매시도 하면, sandbox대신에 Xcode test로 뜬다.

5. 그리고 Debug> StoreKit > Manage Transactions에서 제품을 바꿔보거나 하면 된다.