0

我正在使用我的应用程序中的 NSUser 默认值进行应用内购买.. 一切正常......但是当我在后台删除应用程序时,isPurchased 和 isFailed 的布尔值没有存储......购买一次后......并删除后台应用程序..我的应用程序再次要求购买新关卡..如果我点击购买它显示“您已经购买”并且锁正在打开...但是我想要,如果用户购买了一次关卡在后台删除应用程序后,它不应该要求下次购买...如果不删除后台应用程序它工作正常...我必须做些什么来存储 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;

视图控制器.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);
}
4

0 回答 0