Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to logout/change Twitter account with Parse

I know how to login:

ParseTwitterUtils.logIn(loginView.getCurrentContext(), new LogInCallback() {
    @Override
    public void done(ParseUser parseUser, ParseException e) {
        if (e == null) {
            String welcomeMessage = "";
            if (parseUser.isNew()) {
                welcomeMessage = "Hello new guy!";
            } else {
                welcomeMessage = "Welcome back!";
            }
            loginView.showLoginSuccess(parseUser, welcomeMessage);
        } else {
            String errorMessage = "Seems we have a problem : " + e.getLocalizedMessage();
            loginView.showLoginFail(errorMessage);
        }
    }
});

And to logout :

ParseUser.logOutInBackground(new LogOutCallback() {
    @Override
    public void done(ParseException e) {
        if (e == null) {
            homeView.goLogin(true, "See you soon");
        } else {
            homeView.goLogin(false, "Error detected : " + e.getLocalizedMessage());
        }
    }
});

But when I want to log in again, I don't have the alert dialog asking me to choose accounts (i use the webview since Twitter app is not installed on the emulator).

How to truly logout from Parse using Twitter login?

like image 469
Tsunaze Avatar asked Nov 21 '15 12:11

Tsunaze


1 Answers

In iOS, you can revise the source code of Parse in PFOauth1FlowDialog.m

- (void)loadURL:(NSURL *)url queryParameters:(NSDictionary *)parameters   {
    NSMutableDictionary *_parameter = [[NSMutableDictionary alloc] init];
    [_parameter setObject:@"true" forKey:@"force_login"];
    [_parameter addEntriesFromDictionary:parameters];
    _loadingURL = [[self class] _urlFromBaseURL:url queryParameters:_parameter];
    NSURLRequest *request = [NSURLRequest requestWithURL:_loadingURL];
    [_webView loadRequest:request];
}

Then everything should work fine, And this should also work in Android.

like image 172
高玉璁 Avatar answered Oct 16 '22 15:10

高玉璁