This repository has been archived by the owner on Feb 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRMStore.m
executable file
·569 lines (479 loc) · 21.4 KB
/
RMStore.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
//
// RMStore.h
// RMStore
//
// Created by Hermes Pique on 12/6/09.
// Copyright (c) 2013 Robot Media SL (http://www.robotmedia.net)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "RMStore.h"
NSString *const RMStoreErrorDomain = @"net.robotmedia.store";
NSInteger const RMStoreErrorCodeUnknownProductIdentifier = 100;
NSString* const RMSKPaymentTransactionFailed = @"RMSKPaymentTransactionFailed";
NSString* const RMSKPaymentTransactionFinished = @"RMSKPaymentTransactionFinished";
NSString* const RMSKProductsRequestFailed = @"RMSKProductsRequestFailed";
NSString* const RMSKProductsRequestFinished = @"RMSKProductsRequestFinished";
NSString* const RMSKRefreshReceiptFailed = @"RMSKRefreshReceiptFailed";
NSString* const RMSKRefreshReceiptFinished = @"RMSKRefreshReceiptFinished";
NSString* const RMSKRestoreTransactionsFailed = @"RMSKRestoreTransactionsFailed";
NSString* const RMSKRestoreTransactionsFinished = @"RMSKRestoreTransactionsFinished";
NSString* const RMStoreNotificationInvalidProductIdentifiers = @"invalidProductIdentifiers";
NSString* const RMStoreNotificationProductIdentifier = @"productIdentifier";
NSString* const RMStoreNotificationProducts = @"products";
NSString* const RMStoreNotificationStoreError = @"storeError";
NSString* const RMStoreNotificationStoreReceipt = @"storeReceipt";
NSString* const RMStoreNotificationTransaction = @"transaction";
#ifdef DEBUG
#define RMStoreLog(...) NSLog(@"RMStore: %@", [NSString stringWithFormat:__VA_ARGS__]);
#else
#define RMStoreLog(...)
#endif
typedef void (^RMSKPaymentTransactionFailureBlock)(SKPaymentTransaction *transaction, NSError *error);
typedef void (^RMSKPaymentTransactionSuccessBlock)(SKPaymentTransaction *transaction);
typedef void (^RMSKProductsRequestFailureBlock)(NSError *error);
typedef void (^RMSKProductsRequestSuccessBlock)(NSArray *products, NSArray *invalidIdentifiers);
typedef void (^RMStoreFailureBlock)(NSError *error);
typedef void (^RMStoreSuccessBlock)();
@implementation NSNotification(RMStore)
- (NSArray*)invalidProductIdentifiers
{
return [self.userInfo objectForKey:RMStoreNotificationInvalidProductIdentifiers];
}
- (NSString*)productIdentifier
{
return [self.userInfo objectForKey:RMStoreNotificationProductIdentifier];
}
- (NSArray*)products
{
return [self.userInfo objectForKey:RMStoreNotificationProducts];
}
- (NSError*)storeError
{
return [self.userInfo objectForKey:RMStoreNotificationStoreError];
}
- (SKPaymentTransaction*)transaction
{
return [self.userInfo objectForKey:RMStoreNotificationTransaction];
}
@end
@interface RMProductsRequestDelegate : NSObject<SKProductsRequestDelegate>
@property (nonatomic, strong) RMSKProductsRequestSuccessBlock successBlock;
@property (nonatomic, strong) RMSKProductsRequestFailureBlock failureBlock;
@property (nonatomic, weak) RMStore *store;
@end
@interface RMAddPaymentParameters : NSObject
@property (nonatomic, strong) RMSKPaymentTransactionSuccessBlock successBlock;
@property (nonatomic, strong) RMSKPaymentTransactionFailureBlock failureBlock;
@end
@implementation RMAddPaymentParameters
@end
@interface RMStore() <SKRequestDelegate>
@end
@implementation RMStore {
NSMutableDictionary *_addPaymentParameters; // HACK: We use a dictionary of product identifiers because the returned SKPayment is different from the one we add to the queue. Bad Apple.
NSMutableDictionary *_products;
NSMutableSet *_productsRequestDelegates;
NSInteger _pendingRestoredTransactionsCount;
BOOL _restoredCompletedTransactionsFinished;
SKReceiptRefreshRequest *_refreshReceiptRequest;
void (^_refreshReceiptFailureBlock)(NSError* error);
void (^_refreshReceiptSuccessBlock)();
void (^_restoreTransactionsFailureBlock)(NSError* error);
void (^_restoreTransactionsSuccessBlock)();
}
- (id) init
{
if (self = [super init])
{
_addPaymentParameters = [NSMutableDictionary dictionary];
_products = [NSMutableDictionary dictionary];
_productsRequestDelegates = [NSMutableSet set];
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
}
return self;
}
- (void)dealloc
{
[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
}
+ (RMStore *)defaultStore
{
static RMStore *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[[self class] alloc] init];
});
return sharedInstance;
}
#pragma mark StoreKit wrapper
+ (BOOL)canMakePayments
{
return [SKPaymentQueue canMakePayments];
}
- (void)addPayment:(NSString*)productIdentifier
{
[self addPayment:productIdentifier success:nil failure:nil];
}
- (void)addPayment:(NSString*)productIdentifier
success:(void (^)(SKPaymentTransaction *transaction))successBlock
failure:(void (^)(SKPaymentTransaction *transaction, NSError *error))failureBlock
{
[self addPayment:productIdentifier user:nil success:successBlock failure:failureBlock];
}
- (void)addPayment:(NSString*)productIdentifier
user:(NSString*)userIdentifier
success:(void (^)(SKPaymentTransaction *transaction))successBlock
failure:(void (^)(SKPaymentTransaction *transaction, NSError *error))failureBlock
{
SKProduct *product = [self productForIdentifier:productIdentifier];
if (product == nil)
{
RMStoreLog(@"unknown product id %@", productIdentifier)
if (failureBlock != nil)
{
NSError *error = [NSError errorWithDomain:RMStoreErrorDomain code:RMStoreErrorCodeUnknownProductIdentifier userInfo:@{NSLocalizedDescriptionKey: NSLocalizedString(@"Unknown product identifier", "Error description")}];
failureBlock(nil, error);
}
return;
}
SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];
if ([payment respondsToSelector:@selector(setApplicationUsername:)])
{
payment.applicationUsername = userIdentifier;
}
RMAddPaymentParameters *parameters = [[RMAddPaymentParameters alloc] init];
parameters.successBlock = successBlock;
parameters.failureBlock = failureBlock;
[_addPaymentParameters setObject:parameters forKey:productIdentifier];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
- (void)requestProducts:(NSSet*)identifiers
{
[self requestProducts:identifiers success:nil failure:nil];
}
- (void)requestProducts:(NSSet*)identifiers
success:(RMSKProductsRequestSuccessBlock)successBlock
failure:(RMSKProductsRequestFailureBlock)failureBlock
{
RMProductsRequestDelegate *delegate = [[RMProductsRequestDelegate alloc] init];
delegate.store = self;
delegate.successBlock = successBlock;
delegate.failureBlock = failureBlock;
[_productsRequestDelegates addObject:delegate];
SKProductsRequest *productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:identifiers];
productsRequest.delegate = delegate;
[productsRequest start];
}
- (void)restoreTransactions
{
[self restoreTransactionsOnSuccess:nil failure:nil];
}
- (void)restoreTransactionsOnSuccess:(RMStoreSuccessBlock)successBlock
failure:(RMStoreFailureBlock)failureBlock
{
_pendingRestoredTransactionsCount = 0;
_restoreTransactionsSuccessBlock = successBlock;
_restoreTransactionsFailureBlock = failureBlock;
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
- (void)restoreTransactionsOfUser:(NSString*)userIdentifier
onSuccess:(void (^)())successBlock
failure:(void (^)(NSError *error))failureBlock
{
NSAssert([[SKPaymentQueue defaultQueue] respondsToSelector:@selector(restoreCompletedTransactionsWithApplicationUsername:)], @"restoreCompletedTransactionsWithApplicationUsername: not supported in this iOS version. Use restoreTransactionsOnSuccess:failure: instead.");
_pendingRestoredTransactionsCount = 0;
_restoreTransactionsSuccessBlock = successBlock;
_restoreTransactionsFailureBlock = failureBlock;
[[SKPaymentQueue defaultQueue] restoreCompletedTransactionsWithApplicationUsername:userIdentifier];
}
#pragma mark Receipt
+ (NSURL*)receiptURL
{
// The general best practice of weak linking using the respondsToSelector: method cannot be used here. Prior to iOS 7, the method was implemented as private SPI, but that implementation called the doesNotRecognizeSelector: method.
NSAssert(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1, @"appStoreReceiptURL not supported in this iOS version.");
NSURL *url = [[NSBundle mainBundle] appStoreReceiptURL];
return url;
}
- (void)refreshReceipt
{
[self refreshReceiptOnSuccess:nil failure:nil];
}
- (void)refreshReceiptOnSuccess:(RMStoreSuccessBlock)successBlock
failure:(RMStoreFailureBlock)failureBlock
{
_refreshReceiptFailureBlock = failureBlock;
_refreshReceiptSuccessBlock = successBlock;
_refreshReceiptRequest = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:@{}];
_refreshReceiptRequest.delegate = self;
[_refreshReceiptRequest start];
}
#pragma mark Product management
- (SKProduct*)productForIdentifier:(NSString*)productIdentifier
{
return [_products objectForKey:productIdentifier];
}
+ (NSString*)localizedPriceOfProduct:(SKProduct*)product
{
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
numberFormatter.locale = product.priceLocale;
NSString *formattedString = [numberFormatter stringFromNumber:product.price];
return formattedString;
}
#pragma mark Observers
- (void)addStoreObserver:(id<RMStoreObserver>)observer
{
[self addStoreObserver:observer selector:@selector(storeProductsRequestFailed:) notificationName:RMSKProductsRequestFailed];
[self addStoreObserver:observer selector:@selector(storeProductsRequestFinished:) notificationName:RMSKProductsRequestFinished];
[self addStoreObserver:observer selector:@selector(storePaymentTransactionFailed:) notificationName:RMSKPaymentTransactionFailed];
[self addStoreObserver:observer selector:@selector(storePaymentTransactionFinished:) notificationName:RMSKPaymentTransactionFinished];
[self addStoreObserver:observer selector:@selector(storeRefreshReceiptFailed:) notificationName:RMSKRefreshReceiptFailed];
[self addStoreObserver:observer selector:@selector(storeRefreshReceiptFinished:) notificationName:RMSKRefreshReceiptFinished];
[self addStoreObserver:observer selector:@selector(storeRestoreTransactionsFailed:) notificationName:RMSKRestoreTransactionsFailed];
[self addStoreObserver:observer selector:@selector(storeRestoreTransactionsFinished:) notificationName:RMSKRestoreTransactionsFinished];
}
- (void)removeStoreObserver:(id<RMStoreObserver>)observer
{
[[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKProductsRequestFailed object:self];
[[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKProductsRequestFinished object:self];
[[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKPaymentTransactionFailed object:self];
[[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKPaymentTransactionFinished object:self];
[[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKRefreshReceiptFailed object:self];
[[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKRefreshReceiptFinished object:self];
[[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKRestoreTransactionsFailed object:self];
[[NSNotificationCenter defaultCenter] removeObserver:observer name:RMSKRestoreTransactionsFinished object:self];
}
// Private
- (void)addStoreObserver:(id<RMStoreObserver>)observer selector:(SEL)aSelector notificationName:(NSString*)notificationName
{
if ([observer respondsToSelector:aSelector])
{
[[NSNotificationCenter defaultCenter] addObserver:observer selector:aSelector name:notificationName object:self];
}
}
#pragma mark SKPaymentTransactionObserver
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self paymentQueue:queue completedTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self paymentQueue:queue failedTransaction:transaction error:transaction.error];
break;
case SKPaymentTransactionStateRestored:
[self paymentQueue:queue restoredTransaction:transaction];
default:
break;
}
}
}
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
RMStoreLog(@"restore transactions finished");
_restoredCompletedTransactionsFinished = YES;
[self notifyRestoreTransactionFinishedIfApplicableAfterTransaction:nil];
}
- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
{
RMStoreLog(@"restored transactions failed with error %@", error.debugDescription);
if (_restoreTransactionsFailureBlock != nil)
{
_restoreTransactionsFailureBlock(error);
_restoreTransactionsFailureBlock = nil;
}
NSDictionary *userInfo = nil;
if (error)
{ // error might be nil (e.g., on airplane mode)
userInfo = @{RMStoreNotificationStoreError: error};
}
[[NSNotificationCenter defaultCenter] postNotificationName:RMSKRestoreTransactionsFailed object:self userInfo:userInfo];
}
- (void)paymentQueue:(SKPaymentQueue*)queue completedTransaction:(SKPaymentTransaction *)transaction
{
RMStoreLog(@"transaction purchased with product %@", transaction.payment.productIdentifier);
if (self.receiptVerificator != nil)
{
[self.receiptVerificator verifyTransaction:transaction success:^{
[self paymentQueue:queue verifiedTransaction:transaction];
} failure:^(NSError *error) {
[self paymentQueue:queue failedTransaction:transaction error:error];
}];
}
else
{
RMStoreLog(@"WARNING: no receipt verification");
[self paymentQueue:queue verifiedTransaction:transaction];
}
}
- (void)paymentQueue:(SKPaymentQueue*)queue verifiedTransaction:(SKPaymentTransaction *)transaction
{
SKPayment *payment = transaction.payment;
NSString* productIdentifier = payment.productIdentifier;
[queue finishTransaction:transaction];
[self.transactionPersistor persistTransaction:transaction];
RMAddPaymentParameters *wrapper = [self popAddPaymentParametersForIdentifier:productIdentifier];
if (wrapper.successBlock != nil)
{
wrapper.successBlock(transaction);
}
NSDictionary *userInfo = @{RMStoreNotificationTransaction: transaction, RMStoreNotificationProductIdentifier: productIdentifier};
[[NSNotificationCenter defaultCenter] postNotificationName:RMSKPaymentTransactionFinished object:self userInfo:userInfo];
}
- (void)paymentQueue:(SKPaymentQueue *)queue failedTransaction:(SKPaymentTransaction *)transaction error:(NSError*)error
{
SKPayment *payment = transaction.payment;
NSString* productIdentifier = payment.productIdentifier;
RMStoreLog(@"transaction failed with product %@ and error %@", productIdentifier, error.debugDescription);
[queue finishTransaction:transaction];
RMAddPaymentParameters *parameters = [self popAddPaymentParametersForIdentifier:productIdentifier];
if (parameters.failureBlock != nil)
{
parameters.failureBlock(transaction, error);
}
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
[userInfo setObject:transaction forKey:RMStoreNotificationTransaction];
[userInfo setObject:productIdentifier forKey:RMStoreNotificationProductIdentifier];
if (error)
{
[userInfo setObject:error forKey:RMStoreNotificationStoreError];
}
[[NSNotificationCenter defaultCenter] postNotificationName:RMSKPaymentTransactionFailed object:self userInfo:userInfo];
}
- (void)paymentQueue:(SKPaymentQueue*)queue restoredTransaction:(SKPaymentTransaction *)transaction
{
RMStoreLog(@"transaction restored with product %@", transaction.originalTransaction.payment.productIdentifier);
_pendingRestoredTransactionsCount++;
if (self.receiptVerificator != nil)
{
[self.receiptVerificator verifyTransaction:transaction success:^{
[self paymentQueue:queue verifiedTransaction:transaction];
[self notifyRestoreTransactionFinishedIfApplicableAfterTransaction:transaction];
} failure:^(NSError *error) {
[self paymentQueue:queue failedTransaction:transaction error:error];
[self notifyRestoreTransactionFinishedIfApplicableAfterTransaction:transaction];
}];
}
else
{
RMStoreLog(@"WARNING: no receipt verification");
[self paymentQueue:queue verifiedTransaction:transaction];
[self notifyRestoreTransactionFinishedIfApplicableAfterTransaction:transaction];
}
}
- (void)notifyRestoreTransactionFinishedIfApplicableAfterTransaction:(SKPaymentTransaction*)transaction
{
if (transaction != nil && transaction.transactionState == SKPaymentTransactionStateRestored)
{
_pendingRestoredTransactionsCount--;
}
if (_restoredCompletedTransactionsFinished && _pendingRestoredTransactionsCount == 0)
{ // Wait until all restored transations have been verified
if (_restoreTransactionsSuccessBlock != nil)
{
_restoreTransactionsSuccessBlock();
_restoreTransactionsSuccessBlock = nil;
}
[[NSNotificationCenter defaultCenter] postNotificationName:RMSKRestoreTransactionsFinished object:self];
}
}
- (RMAddPaymentParameters*)popAddPaymentParametersForIdentifier:(NSString*)identifier
{
RMAddPaymentParameters *parameters = [_addPaymentParameters objectForKey:identifier];
[_addPaymentParameters removeObjectForKey:identifier];
return parameters;
}
#pragma mark SKRequestDelegate
- (void)requestDidFinish:(SKRequest *)request
{
RMStoreLog(@"refresh receipt finished");
_refreshReceiptRequest = nil;
if (_refreshReceiptSuccessBlock)
{
_refreshReceiptSuccessBlock();
_refreshReceiptSuccessBlock = nil;
}
[[NSNotificationCenter defaultCenter] postNotificationName:RMSKRefreshReceiptFinished object:self];
}
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
RMStoreLog(@"refresh receipt failed with error %@", error.debugDescription);
_refreshReceiptRequest = nil;
if (_refreshReceiptFailureBlock)
{
_refreshReceiptFailureBlock(error);
_refreshReceiptFailureBlock = nil;
}
NSDictionary *userInfo = nil;
if (error)
{ // error might be nil (e.g., on airplane mode)
userInfo = @{RMStoreNotificationStoreError: error};
}
[[NSNotificationCenter defaultCenter] postNotificationName:RMSKRefreshReceiptFailed object:self userInfo:userInfo];
}
#pragma mark Private
- (void)addProduct:(SKProduct*)product
{
[_products setObject:product forKey:product.productIdentifier];
}
- (void)removeProductsRequestDelegate:(RMProductsRequestDelegate*)delegate
{
[_productsRequestDelegates removeObject:delegate];
}
@end
@implementation RMProductsRequestDelegate
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
RMStoreLog(@"products request received response");
NSArray *products = [NSArray arrayWithArray:response.products];
NSArray *invalidProductIdentifiers = [NSArray arrayWithArray:response.invalidProductIdentifiers];
for (SKProduct *product in products)
{
RMStoreLog(@"received product with id %@", product.productIdentifier);
[self.store addProduct:product];
}
for (NSString *invalid in invalidProductIdentifiers)
{
RMStoreLog(@"invalid product with id %@", invalid);
}
if (self.successBlock)
{
self.successBlock(products, invalidProductIdentifiers);
}
NSDictionary *userInfo = @{RMStoreNotificationProducts: products, RMStoreNotificationInvalidProductIdentifiers: invalidProductIdentifiers};
[[NSNotificationCenter defaultCenter] postNotificationName:RMSKProductsRequestFinished object:self.store userInfo:userInfo];
}
- (void)requestDidFinish:(SKRequest *)request
{
[self.store removeProductsRequestDelegate:self];
}
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
RMStoreLog(@"products request failed with error %@", error.debugDescription);
if (self.failureBlock)
{
self.failureBlock(error);
}
NSDictionary *userInfo = nil;
if (error)
{ // error might be nil (e.g., on airplane mode)
userInfo = @{RMStoreNotificationStoreError: error};
}
[[NSNotificationCenter defaultCenter] postNotificationName:RMSKProductsRequestFailed object:self.store userInfo:userInfo];
[self.store removeProductsRequestDelegate:self];
}
@end