Skip to content

Commit

Permalink
v1.0.1 (#3)
Browse files Browse the repository at this point in the history
* Fixed a crash on logout and unwanted blockage of other plugins.

* Fix #1 by return a NSNull instead of nil when the twitter session is nil.

* Fix #2 by clarifying the documentation. Also explain the toMap and fromMap methods of TwitterSession more clearly.

* Bump the version code and update Changelog.
  • Loading branch information
roughike committed Feb 24, 2018
1 parent 37aec55 commit 52a5f49
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.0.1

* Fixed `onActivityResult` override that was potentially preventing other plugins from receiving `Activity` results.
* Fixed a logout crash on Android in the case when the user wasn't already logged in.
* Fixed #1 by returning NSNull from the `sessionToMap` method when the twitter session is nil.
* Fix #2 by clarifying the documentation. Also explain the `toMap` and `fromMap` methods of `TwitterSession` more clearly.

## 1.0.0

* Initial release.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void onMethodCall(MethodCall call, Result result) {
authorize(result, call);
break;
case METHOD_LOG_OUT:
logOut(result);
logOut(result, call);
break;
default:
result.notImplemented();
Expand Down Expand Up @@ -109,10 +109,12 @@ private TwitterAuthClient configureClient(String consumerKey, String consumerSec
return new TwitterAuthClient();
}

private void logOut(Result result) {
private void logOut(Result result, MethodCall call) {
CookieSyncManager.createInstance(registrar.context());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeSessionCookie();

initializeAuthClient(call);
TwitterCore.getInstance().getSessionManager().clearActiveSession();
result.success(null);
}
Expand Down Expand Up @@ -163,6 +165,6 @@ public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
authClientInstance.onActivityResult(requestCode, resultCode, data);
}

return true;
return false;
}
}
4 changes: 2 additions & 2 deletions ios/Classes/TwitterLoginPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ - (void)authorize:(FlutterResult)result {
}];
}

- (NSDictionary *)sessionDataToMap:(TWTRSession *)session {
- (id)sessionDataToMap:(TWTRSession *)session {
if (session == nil) {
return nil;
return [NSNull null];
}

return @{
Expand Down
9 changes: 4 additions & 5 deletions lib/flutter_twitter_login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class TwitterLogin {

/// Retrieves the currently active session, if any.
///
/// This could be useful for logging in the user automatically in the case
/// where you don't persist the session in your Flutter app yourself.
/// A common use case for this is logging the user automatically in if they
/// have already logged in before and the session is still active.
///
/// For example:
///
Expand Down Expand Up @@ -193,8 +193,7 @@ class TwitterSession {

/// Constructs a new access token instance from a [Map].
///
/// This is used mostly internally by this library, but could be useful if
/// storing the token locally by using the [toMap] method.
/// This is used mostly internally by this library.
TwitterSession.fromMap(Map<String, dynamic> map)
: secret = map['secret'],
token = map['token'],
Expand All @@ -204,7 +203,7 @@ class TwitterSession {
/// Transforms this access token to a [Map].
///
/// This could be useful for encoding this access token as JSON and then
/// storing it locally.
/// sending it to a server.
Map<String, dynamic> toMap() {
return {
'secret': secret,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_twitter_login
description: A Flutter plugin for allowing users to authenticate with native Android &amp; iOS Twitter login SDKs.
version: 1.0.0
version: 1.0.1
author: Iiro Krankka <iiro.krankka@gmail.com>
homepage: https://github.com/roughike/flutter_twitter_login

Expand Down

0 comments on commit 52a5f49

Please sign in to comment.