Includes Google Sign-In SDK v4.0.0
- link the lib with
react-native link react-native-google-signin
- install the Google Signin SDK with CocoaPods (add
pod 'Google/SignIn'
in your Podfile and runpod install
)
- add
ios/RNGoogleSignin.xcodeproj
to your xcode project - In your project build phase ->
Link binary with libraries
step, addlibRNGoogleSignin.a
,AddressBook.framework
,SafariServices.framework
,SystemConfiguration.framework
andlibz.tbd
- Drag and drop the
ios/GoogleSdk
folder to your xcode project. (Make sureCopy items if needed
IS ticked)
-
Open https://developers.google.com/identity/sign-in/ios/sdk/
-
Scroll down and click
Get a configuration file
button -
Download the
GoogleService-Info.plist
file at the end of the process
- Make sure all dependencies are correctly linked to your project:
- Configure URL types in the
Info
panel- add a URL with scheme set to your
REVERSED_CLIENT_ID
(found inside the plist) - add a URL with scheme set to your
bundle id
- add a URL with scheme set to your
Add the end of this step, your Xcode config should look like this:
Inside AppDelegate.m
// add this line before @implementation AppDelegate
#import <RNGoogleSignin/RNGoogleSignin.h>
// add this method before @end
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [RNGoogleSignin application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
Only one openURL
method can be defined, so if you have multiple listeners which should be defined (for instance if you have both Google and Facebook OAuth), you must combine them into a single function like so:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
]
|| [RNGoogleSignin application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation
];
}