简体   繁体   中英

How to test ios11 promoted In-App Purchases

Apple introduced Promoted In-App Purchases in iOS 11. Though I have implemented the new required SKPaymentTransactionObserver method, paymentQueue:shouldAddStorePayment:for:, I have not been able to successfully test "buying" an item. Should one be able to test and purchase in the Sandbox test environment?

Apple does discuss initiating testing through an URL of the form:

itms-services://?action=purchaseIntent&bundleId=com.example.app&productIdentifier=com.example.app.myIAP

I've put the URL in an email to myself. When I click on the URL, I get the following sequence:

1) Switches to MyApp, and shouldAddStorePayment is called with a product with my product identifier, com.example.app.myIAP (encouraging start)

2) Have paymentQueue:shouldAddStorePayment:for: return true.

3) paymentQueue:updatedTransactions: is called, with a transaction in the “purchasing” (but not purchased) state. It has a nil transactionIdentifier.

4) An alert pops up saying to Sign In. I sign in with a sandbox Apple ID - hitting the “Buy” button on the sign in alert.

5) Another pop up saying to Sign In. I sign in with a sandbox Apple ID - hitting the “Buy” button on the sign in alert.

6) paymentQueue:updatedTransactions: is called, with a transaction in the “failed” state. It has a non-nil transactionIdentifier.

Should the shouldAddStorePayment routine be doing something extra?

I submitted the app with the limited testing as described above. And I was able to do real purchases of promoted in-app-purchases.

But there is a chicken and egg scenario here. Now that the items are in the store, I can run against a local/debug build and test from the App Store. But I think I also burned through several Sandbox User IDs trying things out.

Following is a sequence that I can now do.

1) Go to App Store and log out.

2) Build/run your app and use Restore Purchases - logging in with your Sandbox User ID/password.

3) Verify that your Sandbox User is now logged into the App Store (do not log in directly to the App Store with Sandbox User or that user will no longer work.)

4) Find your app and then find the In-App Purchases section with the promoted features. Select a promoted in-app purchase feature.

5) Your app is loaded. After a bit, one gets an alert with: Confirm Your In-App Purchase ---- Do you want to buy XXXX for $0.99? --- [Environment: Sandbox] ---- Cancel / Buy

6) After purchase one gets the alert: You're all set. ---- Your purchase was successful. ---- [Environment: Sandbox] ---- OK

7) if you do this on an item your Sandbox User has already purchased, you get an alert with: You've already purchased this. Would you like to get it again for free? ---- [Environment: Sandbox] ---- Cancel / OK

The point of the above is that you get alert messages like what you saw before rather than the receipt type item popping up from the bottom that you get when you do a real purchase.

Hope this helps, but still not a good answer for first time through.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM