I have tried to use a private method to put the app in background after pressing the Menu button; and the following code works properly:
@implementation ViewCon
Swift 3 solution:
override func viewDidLoad() {
super.viewDidLoad()
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap(gesture:)))
tapRecognizer.allowedPressTypes = [NSNumber(value: UIPressType.menu.rawValue)]
self.view.addGestureRecognizer(tapRecognizer)
}
func handleTap(gesture: UITapGestureRecognizer){
if gesture.state == UIGestureRecognizerState.ended {
let app = UIApplication.shared
app.perform(#selector(URLSessionTask.suspend))
}
}