Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 234aceb

Browse files
committed
fix(iOS): google auth issue for iOS 10 and below
1 parent 733f9b1 commit 234aceb

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

docs/AUTHENTICATION.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,32 @@ Make sure the URL Scheme for `REVERSED_CLIENT_ID` is in `app/App_Resources/iOS/I
536536
</array>
537537
```
538538

539+
*NOTE:* iOS 10 and below issue for Google Auth when opening from a modal.
540+
541+
If you are planning to open Google Auth from a modal view you may encounter this error resulting in nothing happening (no google auth dialog) on iOS 10 and below:
542+
543+
```
544+
Warning: Attempt to present <SFSafariViewController: 0x7fa575968470> on <UILayoutViewController: 0x7fa575e3d710> whose view is not in the window hierarchy!
545+
```
546+
547+
To solve, you will want to pass in the appropriate iOS controller of the active view. This can be accomplished as follows:
548+
549+
```js
550+
firebase.login({
551+
type: firebase.LoginType.GOOGLE,
552+
ios: {
553+
controller: topmost().ios.controller
554+
}
555+
}).then(
556+
function (result) {
557+
JSON.stringify(result);
558+
},
559+
function (errorMessage) {
560+
console.log(errorMessage);
561+
}
562+
);
563+
```
564+
539565
#### Android
540566

541567
1. If you didn't choose this feature during installation you can uncomment `google-services-auth` in `node_modules\nativescript-plugin-firebase\platforms\android\include.gradle`

src/firebase.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ export interface FirebaseCustomLoginOptions {
234234
tokenProviderFn?: () => Promise<String>;
235235
}
236236

237+
export interface LoginIOSOptions {
238+
controller?: any;
239+
}
240+
237241
/**
238242
* The options object passed into the login function.
239243
*/
@@ -245,6 +249,7 @@ export interface LoginOptions {
245249
googleOptions?: FirebaseGoogleLoginOptions;
246250
facebookOptions?: FirebaseFacebookLoginOptions;
247251
customOptions?: FirebaseCustomLoginOptions;
252+
ios?: LoginIOSOptions;
248253

249254
/**
250255
* @deprecated Please use the 'passwordOptions?: FirebasePasswordLoginOptions' object instead.

src/firebase.ios.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,8 @@ firebase.login = arg => {
13731373
}
13741374

13751375
const sIn = GIDSignIn.sharedInstance();
1376-
sIn.uiDelegate = application.ios.rootController;
1376+
// allow custom controller for variety of use cases
1377+
sIn.uiDelegate = arg.ios && arg.ios.controller ? arg.ios.controller : application.ios.rootController;
13771378
sIn.clientID = FIRApp.defaultApp().options.clientID;
13781379

13791380
if (arg.googleOptions && arg.googleOptions.hostedDomain) {

0 commit comments

Comments
 (0)