nativescript-oauth2
nativescript-oauth2 copied to clipboard
iOS Google Login Blank Page
Hi there,
I've been trying for the couple days to get the Oauth 2.0 to work with Google on iOS unfortunately i wasn't able to make it to work.
This is the result i have once i've press the login:

No error appears on the console, or any warning, just a blank page. I've copy the exact lines from the TypeScript example and so far nothing seems to be working. (I created a new project on google and added the right clienID and redirectUri.
Facebook login works like a charm. Can someone please help me?
Thank you in advance
Please find the code that i've used both on the auth-service.ts:
function configureOAuthProviderGoogle(){
const googleProviderOptions: TnsOaProviderOptionsGoogle = {
openIdSupport: 'oid-full',
clientId: '63412479515-rfh5tjsc5i2ndenh94t72l0g8mev7ckp.apps.googleusercontent.com',
redirectUri: 'com.googleusercontent.apps.63412479515-rfh5tjsc5i2ndenh94t72l0g8mev7ckp:/auth',
urlScheme: 'com.googleusercontent.apps.63412479515-rfh5tjsc5i2ndenh94t72l0g8mev7ckp',
scopes: ['email']
};
const googleProvider = new TnsOaProviderGoogle(googleProviderOptions);
return googleProvider;
}
and the info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>org.nativescript.quickmatch</string>
<key>CFBundleURLSchemes</key>
<array>
<string>196774454843344</string>
<string>com.googleusercontent.apps.63412479515-rfh5tjsc5i2ndenh94t72l0g8mev7ckp</string>
</array>
</dict>
</array>
I have the same problem with a custom provider
If it can helps, I have the following errore in console:
topmost() is deprecated. Use Frame.topmost() instead
@alexziskind1 any suggestion?
Please test if this issue also occurs on android.
If you use the same configuration as in the DEMO the difference between google and facebook providers is the following:
- Google: openIdSupport: "oid-full"
- Facebook: openIdSupport: "oid-none"
This changes the way the "login page" is opened.
switch (this.provider.options.openIdSupport) {
case "oid-full":
delegate_1.TnsOAuthClientAppDelegate.setConfig(this, this.provider.options.urlScheme);
this.loginController = tns_oauth_native_view_controller_1.TnsOAuthLoginNativeViewController.initWithClient(this);
break;
case "oid-none":
this.loginController = tns_oauth_login_webview_controller_1.TnsOAuthLoginWebViewController.initWithClient(this);
break;
default:
this.loginController = tns_oauth_login_webview_controller_1.TnsOAuthLoginWebViewController.initWithClient(this);
break;
}
Facebook will use TnsOAuthLoginWebViewController Google will use TnsOAuthLoginNativeViewController
I recently also had an issue with TnsOAuthLoginNativeViewController on iOS - I can imagine your issue is related to mine #116
Can you please give me some more information:
- Do you use some nested router outlets?
- How does you app.component.html look like?
When you try to open google login on iOS and check the logs. Do you find: Presenting view controllers on detached view controllers is discouraged
I had encountered the same problem, same blank page on iOS after google login. At first, my app used a single Frame and everything worked well. But recently I started to use 2 Frames and the Google login did not work anymore.
@mpht I tried your solution and it worked well. Actually, your code makes much more sense for multiple frame app than original one.
@demolot you can try to use my forked repository (https://www.npmjs.com/package/nativescript-oauth2-forked). It contains the code from #116 and some deprecation fix
@imiskuf any chance you could create a PR? Your fork fixes things for me too
Yes a PR on this would be great! Thanks for finding the fix
FYI I get this same outcome when I implement custom UIApplicationDelegate on version 3.0.1 . Not sure why its interfering.