Releases: react-native-google-signin/google-signin
v1.0.0-rc6
1.0.0-rc5
New features
GoogleSignin.isSignedIn()
(#510)
This method may be used to find out whether some user is currently signed in. It returns a promise which resolves with a boolean value (it never rejects). In the native layer, this is a synchronous call. This means that it will resolve even when the device is offline. Note that it may happen that isSignedIn() resolves to true and calling signInSilently() rejects with an error (eg. due to a network issue).
isSignedIn = async () => {
const isSignedIn = await GoogleSignin.isSignedIn();
this.setState({ isLoginScreenPresented: !isSignedIn });
};
Improvements
statusCodes.SIGN_IN_REQUIRED
(#510)
New status code which can be used to determine if user has signed in or not. Meant to be used with signInSilently()
method.
GoogleSignin.signInSilently()
(#510)
Error code can now be statusCodes.SIGN_IN_REQUIRED
if user has not signed in. This is consistent with the underlying native library.
Usage:
getCurrentUserInfo = async () => {
try {
const userInfo = await GoogleSignin.signInSilently();
this.setState({ userInfo });
} catch (error) {
if (error.code === statusCodes.SIGN_IN_REQUIRED) {
// user has not signed in yet
} else {
// some other error
}
}
};
Documentation changes
Added mention where to find what scopes can be used.
v1.0.0-rc4
Breaking Changes
- [All]
GoogleSignin.signInSilently()
previously never rejected: (it either returned user information or resolved withnull
) now,signInSilently
either resolves with user information or rejects with an error. This is more in line with howsignIn
works, and also allows you to find out what went wrong (eg. a network error). (#488)
New Features
Improvements
- [Android] Fixed crash when trying to pass empty object to
GoogleSignin.hasPlayServices()
. Thanks @tvc97! (#495) - [iOS]
GoogleSignin.configure()
: you no longer need to pass theiosClientId
to theconfigure()
call. (#507)
// Before
GoogleSignin.configure({
iosClientId: 'your-client-id', ...otherOptions
});
// After
GoogleSignin.configure(otherOptions);
- We also got lots of changes to documentation made by contributors! Thanks to @SilentChris and @ngraef! Also thanks for all people testing and using this library. 👍
v1.0.0-rc3
RC-3 contains two minor changes
- We have changed the recommended way to use the
hasPlayServices
function. Please see the related readme section for more information. - A new
PLAY_SERVICES_NOT_AVAILABLE
error status code is available. See more information here.
Release 1.0.0-rc2
As we're getting closed to the stable release we wanted to introduce some breaking changes. Notably changes are the library doesn't store signed in user anymore, the shape of the user
object returned from signIn
has changed and currentUserAsync()
method is renamed.
This release also contains contributions from the community. Huge thanks to @thomasw, @KarlosQ, @blitzcrank and @ifsnow and others for their time for this release! Also thank YOU for reporting issues!
Try out the latest RC:
yarn add react-native-google-signin@next
Breaking Changes
❌ Removed GoogleSignin.currentUser()
The library user is responsible for storing the returned user
object. For example, after GoogleSignin.signIn()
you can put the returned user
to component state or similar.
❌ Removed GoogleSignin.getAccessToken()
This method was used to fetch accessToken
after sign in. Now it's part of the response from signIn()
and signInSilently()
method by default thus removing the need of this method altogether.
⚠️ GoogleSignin.configure()
GoogleSignin.configure()
is now sync, does not return a promise. It still needs to be called before any other methods are called such as GoogleSignin.signIn()
.
⚠️ Renamed autoResolve
to showPlayServicesUpdateDialog
In GoogleSignin.hasPlayServices()
you can pass a configuration object { showPlayServicesUpdateDialog: true }
. It defaults to true
if nothing is passed.
⚠️ Renamed GoogleSignin.currentUserAsync()
to GoogleSignin.signInSilently()
GoogleSignin.signInSilently()
is a bit more descriptive and is used in the underlying libraries. The function of the method has not changed. This method is used to sign in previously signed in user.
⚠️ Changed shape of data returned from GoogleSignin.signInSilently()
and GoogleSignin.signIn()
Standardized the returned object's shape to follow how other libraries handle this. Previously we mixed idToken
and some other stuff with user data. Now the shape of the object is:
{
idToken,
serverAuthCode,
accessToken,
user: {
name,
email,
...
}
}
⚠️ Error handling and statusCodes
We've made changes to how errors are handled. You should import statusCodes
from the package and use it to compare error codes. For example:
import { GoogleSignin, statusCodes } from 'react-native-google-signin';
// Later in your code
signIn = async () => {
try {
const userInfo = await GoogleSignin.signIn();
} catch (error) {
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
// sign in was cancelled
} else if (error.code === statusCodes.IN_PROGRESS) {
// operation (f.e. sign in) is in progress already
} else {
// Something else went wrong
}
}
}
statusCodes
currently has these constants defined:
SIGN_IN_CANCELLED
: when user cancels the sign in flowIN_PROGRESS
: trying to invoke another sign in flow when previous one has not yet finished
Deprecations
⚠️ accessTokenExpirationDate
Deprecated for two reasons:
- This has not been available on Android (underlying native library does not support it)
- On iOS this has not been a timestamp but a time interval from token issue date to the expiration date
For these reasons we deprecate it now and will remove it in the future releases. If you believe the information should be returned, please open an issue and explain why it is the case.
Other changes
- 🐛 Fix invalid EMAIL scope specification (#441) (@thomasw)
- 🐛 Update RNGoogleSignin.podspec to define
GoogleSignIn
as a dependency (#458) (@blitzcrank) - ⬆️ Gradle 3.+, RN 0.56.+ and project-wide properties (#462) (@KarlosQ)
- 📝 Readme changes (#466) (@ifsnow)
- 📝 Updated Android installation documentation (#424) (@sortofbusy)
1.0.0-rc1
This is the first release after the repo was moved to react-native-community. You may get it with
yarn add react-native-google-signin@next
With this RC, a lot has changed under the hood. In particular, both native modules were rewritten to use promises internally (before they were event-based). Also, the JS logic that previously lived in two files (one for each platform) were merged into one. These changes enabled to have cleaner code, fixed several bugs along the way and will ease future maintenance. We now hope the lib will be actively maintained and brought to a stable state.
Thanks to @AndreiCalazans and @jozan for helping to manage issues, coding and code reviews. Also thanks to @sibelius who facilitated the move under react-native-community.
Our aim with this RC was to keep breaking changes to a minimum and use this RC for the library users to upgrade easily and report potential bugs.
Since the internals of the library were, from a fair part, rewritten, it is not easy to enumerate all breaking changes. Let us instead describe each function that is exported from JS and its behavior:
configure
: resolves totrue
or rejects with error (should require no changes to your code)hasPlayServices
: resolves totrue
or rejects with error (should require no changes to your code)signOut
: resolves totrue
or rejects with error (should require no changes to your code)currentUserAsync
: no changessignIn
: resolves to user info or rejects with error. In case use cancels the login flow, the rejection error object contains acode
property with valueCANCELED
see readmegetAccessToken
- no changesrevokeAccess
- no changes
Please note that all rejection Errors have a code
property that used to be a number but now is a string, as the rejections are handled with the RN's promise implementation where the code is a string, as seen here.
Also, please note that the package requires newer versions of its native dependencies, please consult the guides.
v0.9.0
Breaking change
React Native updated all imports path in 0.40
. Hence, a breaking change is required.
If you use RN < 0.40
, stick with v0.8.1
.
v0.8.0
v0.7.2
v0.6.0
Android improvements
- install is now easier
signin
andcurrentUserAsync
now give you an accessToken. \ o /
thanks to @charlires @kevinvangelder @alppu and @almost for their contributions
happy coding