我已经实现了SSASide Menu控制器,并且在收到任何通知后,当我显示View控制器时,SideMenu无法正常工作。
我在AppDelegate类中的代码
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID: \(messageID)")
}
let info = userInfo as NSDictionary
let aps = info.value(forKey: "aps") as! NSDictionary
let dic = aps.value(forKey: "alert") as! NSDictionary
let val = dic.value(forKey: "body") as! String
let msg_id = userInfo[gcmMessageIDKey]
let str_screenKey = userInfo[screenKey] as! String
if str_screenKey == "Send_Invitation"{
// UserDefaults.standard.set(val, forKey: "msg_reminder") //setObject
UserDefaults.standard.set(info, forKey: "msg_reminder") //setObject
UserDefaults.standard.set(userInfo[gcmMessageIDKey], forKey: "msg_id") //setObject
UserDefaults.standard.set("yes", forKey: "isMsgAlert") //setObject
isMsgAlert = true
if UserDefaults.standard.bool(forKey: islogin) {
if let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SSASideMenu") as? SSASideMenu {
if let window = self.window, let rootViewController = window.rootViewController {
var currentController = rootViewController
while let presentedController = currentController.presentedViewController {
currentController = presentedController
}
currentController.present(controller, animated: true, completion: nil)
}
}
}
}//If screen check
}
感谢与问候