问题描述
我分为三个部分:
- 扩展:
extension Notification.Name {
static let userSignedIn = NSNotification.Name(rawValue: "userSignedIn")
}
-
发布通知:
if let userIdentifier = UserDefaults.standard.object(forKey: "appleSignIn") as? (String) { let authorizationProvider = ASAuthorizationAppleIDProvider() authorizationProvider.getCredentialState(forUserID: userIdentifier) { (state,error) in switch (state) { case .authorized: print("Account Found - Signed In") dispatchQueue.main.async { NotificationCenter.default.post(name: .userSignedIn,object: nil) } break case .revoked: print("No Account Found") fallthrough case .notFound: print("No Account Found") dispatchQueue.main.async { } default: break } } }
-
接收通知:
NotificationCenter.default.addobserver(self,selector: #selector(profileLaunch(_:)),name: .userSignedIn,object: nil)
解决方法
可能吧!委托没有设置。希望,在这里你得到答案 --> didReceiveRemoteNotification not called,iOS 10