SPLoginViewController记住凭据

Joh*_*ony 5 spotify cocoalibspotify-2.0

在CocoaLibSpotify中,如何让SPLoginViewController存储凭据,以便用户以后可以通过[[SPSession sharedSession] attemptLoginWithStoredCredentials:]自动登录?

iKe*_*dac 10

你没有.

相反,实现该SPSessionDelegate方法-session:didGenerateLoginCredentials:forUserName:并将凭证存储在NSUserDefaults任何内容中(给定的凭证已经加密并且可以安全地以明文形式存储).

下一次你的应用程序启动,如果您有可用的凭据跳过SPLoginViewController完全和使用登录SPSessionattemptLoginWithUserName:existingCredential:rememberCredentials:方法.如果这会生成登录错误,则令牌已失效,您需要让用户再次登录 - 如果用户在生成令牌后更改了密码,则可能会失效.

请注意,rememberCredentials:参数和旧的处理attemptLoginWithStoredCredentials:方式现在被认为已弃用,很快就会消失.