Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 475
anorskdev Avatar asked Sep 21 '17 20:09

anorskdev


People also ask

How do I promote in app purchases?

Promoting in-app purchases requires two steps: Set up in-app purchases in App Store Connect by uploading promotional images for the in-app purchases you'd like to promote. You can then use the App Store Promotions tool in App Store Connect to manage their order and visibility on the App Store.


1 Answers

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.

like image 126
anorskdev Avatar answered Oct 17 '22 02:10

anorskdev