TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

SOLVED: Restore missing purchases

Forums > SwiftUI

My app was rejected yesterday from apple because I haven't added a 'restore missing purchases' button. I've looked up the code and added it but I can't think how i can test it in xcode the simulator. Does anyone know what the best process is to test it? It need to replicate the condition of someone downloading it on another device or deleting it and then downloading it again or even getting a new phone. Thanks

   

If you have add SKPaymentQueue.default().restoreCompletedTransactions() then it should work. The Xcode IAP is limited.

   

I think i've done it but i'm not sure how to simulate this in the simulator. I want to test the code to make sure it works.

   

If you have a button with restoreCompletedTransactions() call then it should work as it a Apple API. The button need to near the Buy button! As I said the Xcode simulator has limited functions. If you resubmit the app and if reviewer have a issue they will tell you!

1      

@Moni  

Testing the "restore missing purchases" functionality in Xcode Simulator can be a bit tricky since the simulator doesn't fully replicate the behavior of a real device, especially when it comes to in-app purchases and restoring purchases. However, you can still test it to some extent by simulating certain scenarios. Here's a general approach you can take:

  1. Add a "Restore Purchases" Button: Make sure you've added the button as required by Apple's guidelines.

  2. Enable In-App Purchases in Simulator: In Xcode, go to the "Features" menu and select "In-App Purchases" to enable in-app purchases in the simulator.

  3. Mock the Restore Process: Since you can't fully replicate downloading the app on another device or getting a new phone, you'll need to mock the restore process. You can do this by adding code to your app that simulates the restoration of purchases when the "Restore Purchases" button is tapped.

  4. Test with Sandbox Account: Use a sandbox tester account to simulate a user who has previously made purchases. You can sign out of the App Store on the simulator and sign in with a sandbox account to test the purchasing and restoration process.

  5. Simulate Different Scenarios: Try various scenarios, such as:

    • Deleting the app and reinstalling it.
    • Signing in with a different Apple ID.
    • Making a purchase on one device and trying to restore it on another.
  6. Check Logs and Console: Keep an eye on the console output in Xcode while testing. It may provide helpful information about the restoration process and any errors that occur.

  7. Beta Testing: Consider beta testing your app on real devices using TestFlight. This allows you to test the app in more realistic scenarios and gather feedback from real users.

Remember that while you can simulate many scenarios in Xcode Simulator, testing on real devices is still essential to ensure the functionality works as expected in real-world conditions.

   

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.