When use TwitterKit the function logOut don't work - objective-c

I need to logout user from my app.
I use TwitterKit/Fabric to logIn.
[TwitterKit logInWithCompletion:^(TWTRSession *session, NSError *error)
{
}];
and try to logOut with this :
[TwitterKit logOut];
the TwitterKit login set the user account in the iPhone -> Settings -> Twitter and
when I try to login again logInWithCompletion automatically the logIn the user
when I use logOut nothing happens.
Would love to hear suggestions to this problem.

[TwitterKit logOut];
It Deletes the local Twitter user session from this app. This will not remove the system Twitter account nor make a network request to invalidate the session.
ref:https://dev.twitter.com/twitter-kit/ios-reference/twitter

Related

QuickBlox : Already logged in Error after Logout

We are using QuickBlox's iOS SDK for chat implementation.
Currently we have only two view controllers 1). Login and 2). UserList
After successful login app moves to UserList view in this view we have Logout button.
According to QuickBlox API we have use below method for logout
[QBUsers logOutWithDelegate:self];
on button click and its delegate method :
- (void)completedWithResult:(Result *)result
{
if([result isKindOfClass:[QBUUserLogOutResult class]]) // QuickBlox User Logout result
{
// Success result
if(result.success)
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
}
}
After successful logout app moves back to login screen.
Problem :
When user clicks on logout and app moves to Login screen and again if user input same user name and password then log prints
Chat App[3183:5903] -[QBChat loginWithUser:] -> return. Already logged in
How to resolve this issue ? OR What is the best practice to implement Login/Logout flow ?
According to SDK reference, exist session, simply user login and login to chat.
1) you need create session. You may create it simply:
[QBAuth createSessionWithDelegate:self];
or with extended request:
QBASessionCreationRequest *extendedAuthRequest = [QBASessionCreationRequest request];
extendedAuthRequest.userLogin = #"garry";
extendedAuthRequest.userPassword = #"garrySant88";
[QBAuth createSessionWithExtendedRequest:extendedAuthRequest delegate:self];
(If you create session with extended request, pass second action)
2) Perform simply login by
[QBUsers logInWithUserLogin:currentUser password:pass delegate:self]
3) after that for using chat:
[[QBChat instance] loginWithUser:currentUser];
For logout you should perform logout methods in back order.
[[QBChat instance] logout];
after that:
[QBUsers logOutWithDelegate:self];
and:
[QBAuth destroySessionWithDelegate:self];
Recreation of session not necessarily. You can create one session and many times login/logout.

How to call - Reset User Password by email

when user tries to log in (does sign in) and forgets his password then he tries to reset his password then how does the app call Rest Password by email, since the user has not signed in-ed to Quickblox yet. Doesn't the user need to be signed in to QuickBlox in order to call an API?
just create session (without user) and reset your password
[QBAuth createSessionWithDelegate:self];
-(void)completedWithResult:(Result *)result{
if(result.success && [result isKindOfClass:QBAAuthSessionCreationResult.class]){
//success
// reset password
[QBUsers resetUserPasswordWithEmail:#"myemail#gmail.com" delegate:self];
}else if (result.success && [result isKindOfClass:Result.class]){
// you did it
}
}
User can use forget password feature if he can't login the app.
So no, user doesn't need to be signed in to QuickBlox in order to call an API.

Error validating access token: User XXX has not authorized application YYY

I am trying to handle permissions errors and basicaly I removed the app from www.facebook.com App Settings.
In the app I am using this method to login:
[FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
For some reason the token is cached and the app is not realizing that I removed the permissions from the web.
So after the openActiveSessionWithReadPermissions the sessions always is open, then I make a request and I get the next response: (not in the error object but in the response):
Error validating access token: User XXX has not authorized application YYY.
So I handle it and because the token is not valid I do this:
[[FBSession activeSession] closeAndClearTokenInformation];
And try again to login, but same issue.
Seems that if a user removes permissions from web the party is over forever??
Any way back?

Facebook Login authentication using PHP SDK doesn't work properly?

When a user comes to my site, i used to open a new window to authenticate the user and ask for permission through my app(call it as UseCase1). But when a user is already logged-in i was trying to fetch the logged-in user info through PHP SDK so that i need not open a new window and check for the same(You will be avoiding opening a new window that closes after a while since the user is already logged in). But the getUser() method doesn't return me anything. The same method works fine when i go through the UseCase1(open new window which closes automatically).
Below is the code i am trying to use:
$facebook = new Facebook(array(
'appId' => $appId,
'secret' => $appSecret,
'oauth' => true
));
$me = $facebook->getUser();
if ($me) {
try {
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
//code to redirect to login url
// USECASE1
// use $facebook->getUser() one USECASE1 is over
// now the user info is generated properly
}
}
All the times the user is going through USECASE1(but with an empty window since user is logged in and already authenticated the app) even though he is already logged-in and already authenticated the app previously.
Any idea why this is happening
In your code, if the user is getting to 'USECASE1', then it shows that '$me' is being set, because it is getting to your try/catch.
Using $me = $facebook->getUser(); is not a test for whether a user has accepted permissions for your application yet.
I suspect that the reason for the 'FacebookApiException' Exception being thrown is because you haven't got your user permissions yet.
I'd suggest reading the authentication flow and the example PHP SDK authentication flow, see the following links:
http://developers.facebook.com/docs/reference/php/facebook-api/
http://developers.facebook.com/docs/authentication2/

Facebook PHP SDK 3.0 (check if user is logged in)

I'm trying to use the Facebook PHP SDK 3.0 to be able to know if a user is currently logged on into his facebook account to display his information.
This is the flow:
User comes to my site and connects his account with my facebook app.
User is now logged in on my site, my site can access his information.
User logs out of facebook.com.
User refreshes my page.
User is logged out of my site.
User logs in on facebook.com.
User refreshes my page.
USER SHOULD BE LOGGED IN ON MY SITE BUT ISN'T.
When you use the Javascript SDK, you can check if user is logged in and everything works fine with the steps. What needs to be done with the PHP SDK 3.0? I don't want to give access_offline permissions, I just want to be able to access the user when he's logged in on facebook.com.
Thanks a lot,
Jeremie
Add this javascript in all pages(core js).
login() and logout() are functions for your system login and logout.
By this it will check every time fb is logged in or not and call function for login.
And will satisfy condition -
USER SHOULD BE LOGGED IN ON MY SITE BUT ISN'T.
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: '113700398662301', status: true, cookie: true, xfbml: true});
/* All the events registered */
FB.Event.subscribe('auth.login', function(response) {
// do something with response
login();
});
FB.Event.subscribe('auth.logout', function(response) {
// do something with response
logout();
});
FB.getLoginStatus(function(response) {
if (response.session) {
// logged in and connected user, someone you know
login();
}
});
};
</script>
based on the signed request, u should be able to know if the user has authorized your app before.
This should give u some status about the user.
to check if he is logged in to fb, for authorized user, u can try to query "/me" and see if you can query it successfully