Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
454 views
in Technique[技术] by (71.8m points)

iphone - How to test IAP (in-app purchase) in iOS Simulator OR on the Device?

I've implemented a simple non-consumable in-app purchase mechanism by following the Ray Wenderlich tutorial book.

When my app starts, I initiate a product info request:

self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
_productsRequest.delegate = self;
[_productsRequest start];

The SKProductRequest gets created. It has a memory address but nothing else happens. None of the delegate methods gets called:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
    NSLog(@"Product info received...");
    NSArray *products = response.products;
    for (SKProduct *product in products) {
        NSLog(@"ID: %@, title:%@, (%f)", product.productIdentifier, product.localizedTitle, product.price.floatValue);
    }

    self.productsRequest = nil;
}

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {
    NSLog(@"Failed to load list of products");
    self.productsRequest = nil;
}

I checked twice:

  • App fully set-up in iTunes Connect.
  • Status of app in ITC is "Prepare for Upload"
  • One non-consumable IAP added.
  • Status of IAP product in ITC is "Ready to Submit"
  • App ID is com.mycompany.myapp both for the app and in the plist. Checked twice.
  • IAP uses com.mycompany.myapp.productname (using exact same ID for the request).
  • Created a test user account in ITC.
  • Nothing submitted to Apple yet.
  • My Mac has internet access.
  • There are no other messages in the console or on screen.

The Ray Wenderlich book doesn't mention I must do anything else besides this.

Only once I saw a -didFailWithError: call to my delegate on the Device, but it never again appeared. My delegate doesn't get called both on device or simulator. I let it run for minutes with no response at all.

iTunes Connect gives this confusing warning:

Your first In-App Purchase(s) must be submitted with a new app version. Select them from the In-App Purchases section of the Version Details page and then click Ready to Upload Binary.

Is this required prior to being able to test In-App Purchases?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In the current version of Xcode 5.0 (5A1413), In-App purchases will not work in the iOS simulator.

StoreKit (In-App purchases) will not work in the Simulator. 13962338

Source: Xcode 5.0 Release Notes > Known issues > iOS Simulator https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/xc5_release_notes/xc5_release_notes.html#//apple_ref/doc/uid/TP40001051-CH2-SW303


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...