Capacitor: in-app navigation + custom URL redirect - auth0

In my Capacitor app I am able to open a new window to facilitate a login (with Auth0). Upon successful login it opens a Custom URL Scheme (which is registered in the Capacitor app). It does prompt to say Open In "my_app"? in iOS, but selecting Open does send me back to the app.
I would like to do this same thing, but without opening a new browser window, and without the prompt. Essentially without leaving the app.
My attempt at this was to set up my allowNavigation settings in capacitor.config.json, so that my auth provider is opened in-app. This worked, but after a successful login it just hangs. It doesn't prompt to open in the app or anything.
What sort of callback URL would be used for an in-app browser capacitor app? Would a universal/custom URL scheme be needed?

I realized that my problem here was the unexpected way to import the Capacitor Browser plugin. Once I imported like the Docs said, the in-app browser window worked great. I also removed these URLs from the allowNavigation setting (as in my case they are external and not controlled by us).
import { Plugins } from '#capacitor/core';
const { Browser } = Plugins;
...
await Browser.open({ url: 'http://capacitorjs.com/' });

Related

Expo AuthSession new window not redirecting on Web

We are using AuthSession.startAsync to initiate an authentication process in our app, which is working fine on iOS and Android. However when we run it the web browser, instead of redirecting to the correct Auth0 sign in page, our sign in process is just opening another window of the app.
Code that’s causing the problem:
const result = await AuthSession.startAsync({
authUrl,
returnUrl: Platform.OS === 'web' ? getRedirectUri() : undefined,
});
Right now the authUrl is the correct url we need going to auth0, however it doesn’t open this url the way it does on mobile for signing in. Has anyone ran into this AuthSession issue before on an Expo web app?
Thanks in advance!
You need to call WebBrowser.maybeCompleteAuthSession();.
There is a warning in the AuthSession Expo Docs about this case:
🚨 In order to close the popup window on web, you
need to invoke WebBrowser.maybeCompleteAuthSession().
See the Identity example for more info.
The example they are talking about can be found here:
https://docs.expo.dev/guides/authentication/#identityserver-4
Just add WebBrowser.maybeCompleteAuthSession(); under imports in your login component file. Opened window will resolve correctly in Web.
It is not needed in android or ios app.

Why dynamic links in React Native are opening the browser first?

I'm trying to communicate two React Native apps using Firebase Dynamic Links, only in Android.
When I execute openLink with the URL of the other, I see the browser for a second, and then it opens the other app well.
I don't want to see an intermediate browser before open the other app.
I'm having that issue from app A to B, and viceversa.
So, why is the browser opening first? And how can I configure the apps in order to not open the browser?
it's default behavior of android devices.
usually if any link supported by app and its set default to open link then it will open directly otherwise android system opens browser and based on Link URI scheme navigate to app.
there is one solution,
You can create module (intent activity) which will launch that app directly.
Steps to follow
pass data from js to native module and from that use Intent class, set data and start it.
this was for Android use case.

3r Party AuthProvider - callback url redirect

My project includes the firebase sign-in methods: Twitter, Facebook, Google and Github.
I am using firebase.auth().signInWithPopup() to handle authentication and callback. It works fine when run in the browser:
in mobile, this is different. I realize that it opens a new safari window, but it does not redirect to the app home screen. How can we do that?
this is the project in the firebase console for the Facebook sign-in
I believe this is a known issue for home screen apps in iOS. The window that is opened is sandboxed from the home screen app. The popup is unable to pass back the result to the parent home screen app. Instead, you should use signInWithRedirect in that mode. I believe that should work.

signInWithPopup doesn't work on android(Ionic 2 + Firebase 3)

I want to use signInWithPopup in my Ionic 2+Firebase 3 application! It works great on the desktop browser but, when i generate APK for android, it throws network error in auth.js before popup appears. Then, i enter credentials and after that app's blank screen appears. Thanks in advance
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you Access Token. You can use it to access the Google API.
this.navCtrl.push(WriteReviewPage);
// ...
}).catch(function(error) {
alert(error.message);
});
}
signInWithPopup() doesn't work on Ionic/Cordova apps yet.
There's a workaround tho, you need to install the Google Sign-in plugin
The way that works is that you use the plugin to log the user in, and then you pass those credentials to Firebase.
I made something for Facebook authentication you'll follow the same process but with the Google plug-in instead.

FirebaseSimpleLogin not working in Windows 8 app

I asked a question earlier about if it was possible to use Firebase in a Windows 8/WinJS app. #MichaelLehenbauer told me that I just needed to add the following line to my code in order to fix a bug in firebase.js:
Firebase.INTERNAL.forceWebSockets()
This worked great and allowed me to read and write to my Firebase. However, now I am trying to get auth working in Windows 8 and running into many issues. I am trying to use the Facebook login but when I call auth.login("facebook"), my app loses focus and a new tab in the modern Internet Explorer app (not the desktop app) is opened with the typical Facebook login prompt. If I put in my credentials and hit login, nothing happens. I need to go back to my app but then it fires up a new IE tab and the process starts again. Instead of opening a new IE tab, Firebase should internally be opening an in-app dialog like seen in the top image here.
So, since I couldn't get the Firebase Facebook login working in WinJS, I tried doing the Facebook login myself and then create Firebase users using the email/password auth. However, when I run:
auth.login("password", {
email: "me#example.com",
password: "password"
});
I get the following warning (which is the same warning I received from firebase.js befoore Michael suggested to me to force web sockets):
APPHOST9601: Can’t load <https://auth.firebase.com/auth/firebase?&firebase=[my_firebase]&transport=jsonp&email=me%40example.com&password=password&callback=FirebaseSimpleLogin._callbacks._firebaseXDR13889674277557>. An app can’t load remote web content in the local context.
I'm not sure if this is another web sockets issue or not, but it looks like FirebaseSimpleLogin is just not working very well in Windows 8 apps. Are there any workarounds to these problems? Even better, is there any plan to provide full support out of the box with Windows 8?
Windows 8 is now supported out of the box with Firebase Simple Login.