我正在使用我的应用程序中的NSUser默认值进行应用内购买..一切正常......但是当我在后台删除应用程序时,isPurchased和isFailed的Bool值不存储...购买后...并在后台删除应用程序..我的应用程序再次要求购买新的水平..如果我点击购买它显示“你已经购买”和锁是打开...但我想,如果用户购买一旦在后台删除应用程序后不应该要求购买的级别...如果不在后台删除应用程序它工作正常...我必须做什么来存储isPurchased和isFailed值删除后背景中的应用程序..当在main.m中的后台自动释放池中删除应用程序时正在调用..
enter code here
AppDelegate.m
MyStoreAbserver *observer = [[MyStoreAbserver alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];
if([[[NSUserDefaults standardUserDefaults] objectForKey:@"isPurchased"] isEqualToString:@"true"])
isPurchased = YES;
else
isPurchased = NO;
isFailed = NO;
ViewController.m
-(void)callInAppPurchase
{
if ([SKPaymentQueue canMakePayments])
{
// Display a store to the user.
[self requestProductData];
waitLabel.text = @"Please Wait...";
//[self showLoadingState];
SKPayment *payment = [SKPayment paymentWithProductIdentifier:kPaper1Identifier];
[[SKPaymentQueue defaultQueue] addPayment:payment];
else
{
// Warn the user that purchases are disabled.
UIAlertView *alertMsg = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"In App Purchases are disabled in your Apple account, to buy the coupon please enable In App Purchases for your Apple account." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK",nil];
[alertMsg show];
[alertMsg release];
}
}
- (void) requestProductData
{
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:kPaper1Identifier]];
request.delegate = self;
[request start];
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
waitLabel.text = @"";
[request release];
NSLog(@"the details of the product are %@",response.products);
}