robotmedia / RMStore

A lightweight iOS library for In-App Purchases
Apache License 2.0
2.43k stars 450 forks source link

A easy step by step somewhere ? #129

Closed linked67 closed 9 years ago

linked67 commented 9 years ago

I try to use this nice library and understand most of it but i don't understand when i should call the different part.

It would be nice to have something like this

To buy a in app you have to make this in order: -Request products -Add payment

To check some in app when app did become active or on start: -restore transaction ??? -refresh receipt ???

I don't know when i should restore or refresh something and i can bet i'm not alone. The only way to understand what i should do is to read the long doc from apple and compare it with this library.

It's supposed to spare me some time to use RMStore and a clear step by step with minimal explanation on why it must be like this would be nice.

hpique commented 9 years ago

@linked67 I'm afraid RMStore is not designed to save you the time from reading the Apple documentation. It's meant to save you the time from writing most -if not all- of the boilerplate code (which, in my opinion, is various orders of magnitude higher than the reading time).

RMStore makes working with StoreKit more convenient, but it doesn't hide the complexity of its domain.

Of course, someone could write documentation using RMStore as the starting point. I'm aware of a paid tutorial for in-app purchases using RMStore but I can't endorse it as -being closed source- I haven't reviewed it. If you write or find a good free tutorial, please let me know.

linked67 commented 9 years ago

Thanks for your answer. I have read the Apple documentation but still have some basic questions.

For example, I have a IOS7+ app and need a "Ads Remove" purchase. Since i don't trust NSUserDefaults, the receipt seems more secure. I should use RMStoreAppReceiptVerificator and RMStoreKeychainPersistence but for me, a InApp Purchase beginner point of view, it's unclear how i must use them.

Do they do all the job in backgroud or should i write some code to play with these two ?

From the Demo project, i understand well how to make a buy or restore, it's clear but there is no example on how to use receipt/persistence (or maybe i just don't understand).

In the AppDelegate we have this:

- (void)configureStore
{
const BOOL iOS7OrHigher = floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1;
_receiptVerificator = iOS7OrHigher ? [[RMStoreAppReceiptVerificator alloc] init] : [[RMStoreTransactionReceiptVerificator alloc] init];
[RMStore defaultStore].receiptVerificator = _receiptVerificator;
_persistence = [[RMStoreKeychainPersistence alloc] init];
[RMStore defaultStore].transactionPersistor = _persistence;
}

Converted to IOS7+ give me:

receiptVerificator = [[RMStoreAppReceiptVerificator alloc] init];
[RMStore defaultStore].receiptVerificator = receiptVerificator;

persistence = [[RMStoreKeychainPersistence alloc] init];
[RMStore defaultStore].transactionPersistor = persistence;

Or more compressed:

    [RMStore defaultStore].receiptVerificator = [[RMStoreAppReceiptVerificator alloc] init];
    [RMStore defaultStore].transactionPersistor = [[RMStoreKeychainPersistence alloc] init];

But in this case i get a warning "Assigning retained object will be released after assignment", that make me think the RMStore singleton (?) don't keep some value accross different files ?

Well, I just need short "best practice" on how to use receipt/persistence (not from Apple but from RMStore). For the moment, the best i can do is take a couple of hours to browse RMStore code and take a look inside it.

I can bet "Ads remove" is probably the most used InApp purchase. A full demo code that show how to manage RMStoreKeychainPersistence/RMStoreAppReceiptVerificator would be very nice.

Sorry to bother you with so basic questions and thanks for this library.

hpique commented 9 years ago

@linked67 Please use StackOverflow for support as indicated in CONTRIBUTING.md. I often reply there but also others do.

linked67 commented 9 years ago

I have think the author of RMStore is the most able to put a full working demo on something simple like a "Ads remove" (or any other name) purchase with full code that manage receipt/persistence.

It should not be on StackOverflow but here.

On a side note, i already have ask for help there without luck: http://stackoverflow.com/questions/27771785/rmstore-and-simple-remove-ads