1

I am implementing Spotify in iPhone. After the user is logged in to the Spotify in my application, I want to keep the user as logged in until he click logout button, ie, even after the application terminate and relaunch, I should get the session. How can we implement it. Please help.

Tinku George
  • 195
  • 2
  • 11

1 Answers1

2

You need to read this Forum

Save Spotify Session

And also read remember credentials

Enjoy Programming

Community
  • 1
  • 1
Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34
  • Thanks for your response. I got the credential in . But did not understand that how do we get the result of '[[SPSession sharedSession] attemptLoginWithUserName:credential existingCredential:userName];'. – Tinku George Dec 15 '12 at 06:00
  • attempt login works on existingCredential.Spotify generates your session & other login credentials using didGenerateLoginCredentials method. Where you are also asked to store your session & other login credentials in preferences.After that using existingCredential method spotify compares your storage with its. Thus user is able to login with remember me functionality. – Niru Mukund Shah Dec 15 '12 at 06:13
  • I got the credential and username. Then from next time app launch, I am calling '[[SPSession sharedSession] attemptLoginWithUserName:credential existingCredential:userName];'. How can I get logged in. Also didn't understand remember me functionality. Please help. – Tinku George Dec 15 '12 at 06:26
  • When you login first time are you calling -(void)session:(SPSession *)aSession didGenerateLoginCredentials:(NSString *)credential forUserName:(NSString *)userName method? – Niru Mukund Shah Dec 15 '12 at 06:36
  • Yes. I get call back in the function. – Tinku George Dec 15 '12 at 06:58
  • fine then as I mentioned in first comment spotify generates & stores credentials using this method. – Niru Mukund Shah Dec 15 '12 at 07:08
  • Ok. But in next launch, Ishould call 'attemptLoginWithUserName: existingCredential:' right? After that how do I know that I logged in. Is there any call back for 'attemptLoginWithUserName: existingCredential:'. – Tinku George Dec 15 '12 at 07:22
  • after attemptLoginWithUserName call the class that you want to be appeared after spotify login. Thus you will find yourself ogin into spotify – Niru Mukund Shah Dec 15 '12 at 07:26
  • I got the real problem, ie, in my iPhone with iOS 5, it works fine. But in my iOS 6 iPhone, it takes more than 5 minutes to get the response. Do you have any idea. – Tinku George Dec 15 '12 at 09:27
  • SPSession has the delegate methods `sessionDidLoginSuccessfully:` and `session:didFailToLoginWithError:`. Implement those to be notified when login succeeds or not. – iKenndac Dec 16 '12 at 11:18
  • Yes. I am getting those callbacks in my iOS5 device. But in iOS6 device, it takes more than 5 minutes to get the callbacks. – Tinku George Dec 17 '12 at 08:50