Skip to content
This repository

Refresh Products #75

Open
MartinMoizard opened this Issue · 4 comments

4 participants

Martin Moizard Arman Dezfuli-Arjomandi Philippe Converset Aled Brown
Martin Moizard

Currently the products (as SKProducts) are fetched when the shared instance is initialized (most of the time in the app delegate, when the app launches).

So if a user starts the app with no internet acess, no product is fetched.

I didn't find a way yet, with the current version to fetch again products. I'll fork the project and add a method to refresh the products if no one sees a quick and elegant way to do that :)

Thanks

Arman Dezfuli-Arjomandi

Yes! I need this.

Arman Dezfuli-Arjomandi

This is actually a really easy fix. In the method

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response

I just changed the line

[self.purchasableObjects addObjectsFromArray:response.products];

to

if (!isProductsAvailable) [self.purchasableObjects addObjectsFromArray:response.products];

and added this public method on MKStoreManager which I call to preload the data well before it's needed:

- (void)reloadProducts {
    [self requestProductData];
}

Works like a charm :)

Philippe Converset

Yes we need that!

To make it work, I also had to change this line in the [productRequest: didReceiveResponse:]

isProductsAvailable = YES;

to

isProductsAvailable = (self.purchasableObjects.count > 0);
Aled Brown

This issue is absolutely critical. Thanks so much for fixing it guys. I hope it gets fixed in the main project as it nearly made me abandon an otherwise amazing project. Now when internet rechability changes in my app the store will spring back into life. Previously if there was no net connection when the app launched but a net connection became available later the in-app purchases wouldn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.