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

后端 未结 6 1401
一向
一向 2020-12-10 00:31

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 requ

相关标签:
6条回答
  • 2020-12-10 01:11

    In iOS simulator documentation it is written :

    API Limitations

    Within iOS Simulator, there are some limitations to the APIs and features, including:

    Apple Push Services
    Privacy alerts for access to Photos, Contacts, Calendar, and Reminders
    The UIBackgroundModes key
    iCloud document syncing and key-value storage support
    

    Unsupported frameworks include:

    External Accessory
    Media Player
    Message UI 
    Event Kit
    In UIKit, the UIVideoEditorController class
    Store Kit
    

    As in-app purchase needs Store Kit to work and the Store Kit framework is unsupported for Simulator, you can't test IAP in iOS Simulator.

    More information : iOS Simulator documentation

    0 讨论(0)
  • 2020-12-10 01:14

    I figured out something:

    I initiated the SKProductRequest immediately at the end of AppDelegate's -didFinishLaunching... and it never worked.

    Then I made a delayed call and waited 3 seconds. From then on it started working. So you can't make StoreKit requests immediately after app launch.

    0 讨论(0)
  • 2020-12-10 01:16

    Unfortunately there are several things you can not test on the simulator. In App Purchases belongs in that list.

    So you can not test In App Purchases in simulator, you need an iOS device for that.

    Edit: As far as I can see, that is what happens when you try to test IAP on the simulator, purchase delegates won't get called.

    0 讨论(0)
  • 2020-12-10 01:16

    You can test in-app purchases in Xcode 12 from Apple documentation

    https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_in_xcode?language=objc

    And custom manual

    https://www.appcoda.com/storekit-testing/

    0 讨论(0)
  • 2020-12-10 01:20

    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

    0 讨论(0)
  • 2020-12-10 01:37

    Where is your skProductRequest object is declared? Try a global declaration of skProductRequest.

    0 讨论(0)
提交回复
热议问题