如何在HockeyApp反馈功能中登出已登录用户?
Logging out a user from HockeyApp Feedback Manager
Hey there, I’ve dealt with this exact gap in HockeyApp’s documentation before—frustrating that there’s no explicit logout() method exposed, right? Here’s how I implemented it in my projects:
Step-by-Step Implementation
You can force the feedback manager to reset its authenticated state by targeting internal APIs and clearing stored user data. Here’s a complete logout() function:
func logout() { // Clear active authentication session BITHockeyManager.shared().feedbackManager.authenticator.clearAuthentication() // Reset the feedback manager's internal state (clears existing conversations, etc.) if let feedbackManager = BITHockeyManager.shared().feedbackManager as? BITFeedbackManager { feedbackManager.reset() } // Optional: Clear stored user preferences (email/name) from UserDefaults let userDefaults = UserDefaults.standard userDefaults.removeObject(forKey: "BITFeedbackUserEmail") userDefaults.removeObject(forKey: "BITFeedbackUserName") userDefaults.synchronize() }
Breakdown of What Each Line Does:
clearAuthentication(): This wipes the active auth session tied to the feedback feature, immediately unlinking the current user.reset(): Resets the feedback manager’s internal state, including cached conversations and user context. This ensures the next time you callshowFeedbackListView(), it loads a fresh, unauthenticated state.- Clearing UserDefaults entries: HockeyApp stores basic user info (like email/name) locally by default. Removing these ensures the next feedback session doesn’t auto-populate with the previous user’s details.
Notes:
- This won’t affect other HockeyApp features (like crash reporting) since we’re only targeting the
feedbackManager. - While these APIs aren’t prominently documented, they’re stable in all recent versions of the HockeyApp SDK for iOS.
内容的提问来源于stack exchange,提问作者Daniel Klöck
相关产品推荐
相关产品推荐

