In-app purchases: viewing crash

My application has a panel containing 4 view controllers. The third view controller contains “in-store in-app purchases”. In this controller, I use an object that controls in-app purchases (product request, purchase, transaction, etc.), which allow me to get and show the ecc price description.

The problem is this: if I change the tabs while starting the request, the application sometimes crashes, but not always.

Do I need to cancel a request in viewDidDisappear? [productsRequest cancel] this code failed.

0
ios objective-c in-app-purchase
01 Oct 2018-11-11T00:
source share
3 answers

I have the same problem. To fix this, cancel the request and everything will be in order.

var request: SKProductsRequest! //global to cancel when disappear //request products when you want (viewDidLoad for example) request = SKProductsRequest(productIdentifiers: productID as! Set<String>) request.delegate = self request.start() 

And when the view manager disapear:

  override func viewDidDisappear(animated: Bool) { super.viewDidDisappear(animated) request.delegate = nil; request.cancel() SKPaymentQueue.defaultQueue().removeTransactionObserver(self) } 
+1
May 17 '16 at 16:39
source share

Your problem is probably not related to in-app purchase. Somewhere in your code, you are sending a message about the object that was released. Running the analyzer may help you find the error, but this time it may not be necessary. If [productRequest cancel] fails, then it is likely that Request products have a too low retention rate.

0
Oct 02 '11 at 18:21
source share

Remove TransactionObserver while your viewDidDisappear :

 [[SKPaymentQueue defaultQueue]removeTransactionObserver:self]; 

If you return from Inapp View Manager to another View Manager, then

 [[SKPaymentQueue defaultQueue]removeTransactionObserver:self]; [self dismissViewControllerAnimated:YES completion:NULL]; 
-one
Apr 20 '16 at 11:13
source share



All Articles