Search code examples
iosobjective-cswiftstorekitios-extensions

SKStoreProductViewController's cancel button leaving a white, blank screen


I made a quick sample project with an Action Extension for iOS 9. It works properly in my containing app, but it does NOT in my extension. I used the same code in both view controllers.

The button that presents a store product view controller:

@IBAction func storebutton(sender: AnyObject) {
    let storeViewController = SKStoreProductViewController()
    let parameters = [SKStoreProductParameterITunesItemIdentifier: NSNumber(integer: 377298193)]
    storeViewController.delegate = self
    storeViewController.loadProductWithParameters(parameters, completionBlock: nil)
    self.presentViewController(storeViewController, animated: true) { () -> Void in }
}

Delegate Method:

//MARK: SKStoreProductViewController Delegate
func productViewControllerDidFinish(viewController: SKStoreProductViewController) {
   print("Delegate")
   viewController.dismissViewControllerAnimated(true,completion: nil)
}

When I tap the Cancel button on the Store Product View that was from my Action Extension, the store view is dismissed. But its delegate method never gets called and the whole screen remains totally white - never gets back to Action Extension's view.

Can anyone help me please?


Solution

  • Never mind. I found out the delegate method was outside of the Class. I did not know Xcode does not warn about it.