Skip to content

Latest commit

 

History

History
75 lines (49 loc) · 2.86 KB

ios-guide.md

File metadata and controls

75 lines (49 loc) · 2.86 KB

iOS Guide

Includes Google Sign-In SDK v4.0.0

1. Installation

Automatic

  • 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 run pod install)

Manual

  • add ios/RNGoogleSignin.xcodeproj to your xcode project
  • In your project build phase -> Link binary with libraries step, add libRNGoogleSignin.a, AddressBook.framework, SafariServices.framework, SystemConfiguration.framework and libz.tbd
  • Drag and drop the ios/GoogleSdk folder to your xcode project. (Make sure Copy items if needed IS ticked)

2. Google project configuration

3. XCode configuration

  • Make sure all dependencies are correctly linked to your project:

link config

  • 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 the end of this step, your Xcode config should look like this:

xcode config

Project setup

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
            ];
}