Firebase authWithOAuthPopup returns TRANSPORT_UNAV

2020-03-27 03:54发布

问题:

I have had success using the authWithOAuthPopup in my html5 application but when I recently created a phoneGap build, it fails on Android.

I have done the obvious thus far that Ive found from other sources:

Added sources to config.xml:

<access origin="*.firebaseio.*" />
<access origin="https://auth.firebase.com" />

Ive also added the InAppBrowser plugin:

<gap:plugin name="org.apache.cordova.inappbrowser" />

In my test, Im able to call window.open on my phone and get another web page to come up so I know the plugin seems to work.

However, when I use the firebase code, Im unable to get any Auth method to work.

Here is some sample code:

rootRef.authWithOAuthPopup(provider, function (err, user) {
if (err) {
if (err.code === "TRANSPORT_UNAVAILABLE") {
// fails here
}
}});

Can anyone tell me what could be wrong?

回答1:

I solved it by adding this line: <script src="phonegap.js"></script>



回答2:

Adding the below link

<script src="phonegap.js"></script>

Does not work for

firebase.auth().signInWithPopup(provider).then(function(result) {

even after adding

<access origin="*.firebaseio.*" />
<access origin="https://auth.firebase.com" />