-
Notifications
You must be signed in to change notification settings - Fork 121
Integrate InAppPurchaseStore with networking #7883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
You can test the changes from this Pull Request by:
|
|
@toupper this isn't really working until the backend is ready, but maybe we can review, merge into trunk, and take it from there? |
|
Thanks @koke! The code looks good. Perhaps we could add some unit tests, or aren't they necessary at this point?
Yeah, I don't see any reason why not merging that into trunk already 👍 |
| public class InAppPurchaseStore: Store { | ||
| private var listenTask: Task<Void, Error>? | ||
| private let remote: InAppPurchasesRemote | ||
| private var useBackend = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering, what will be the usage of this property? How are we going to set it? I see that it is a private var, but I don't see any place where we change its value :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I wanted to make it configurable through the debug screen, but it got a bit complicated. I left that there so it was easier to change behavior during development/testing.
| private var useBackend = true | ||
|
|
||
| public override init(dispatcher: Dispatcher, storageManager: StorageManagerType, network: Network) { | ||
| remote = InAppPurchasesRemote(network: network) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could inject the remote so we can mock if required when testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at all the other stores in AuthenticatedState, I don't think we typically inject remotes, but instead allow injecting a mock Network to simulate network responses
I thought about those, but I wanted to prioritize getting to a point where we could test the integration first. Also, I wasn't very confident about writing the unit tests until we could do some more manual testing. I added a note to the project to consider adding more tests later |
Closes: #7836
Description
This PR makes the
InAppPurchaseStoreactually talk to our servers to get the list of products and report any purchases. I left auseBackendproperty in the store to quickly switch the behavior back to local-only, since the endpoints aren't working yet.Testing instructions
This PR still uses a StoreKit configuration file by default. This makes it possible to test on simulator, but the receipts won't validate with Apple's servers. On the other hand, using the IAP sandbox servers will work for validation, but testing has to be done on a real device and requires some extra setup. To change whether a StoreKit configuration file is used, in Xcode go to Product > Scheme > Edit Scheme, and change the setting in the Options tab.

More documentation on testing IAP with sandbox here.
RELEASE-NOTES.txtif necessary.