Javascript Firebase身份验证、phonegap构建和deviceready事件
我想通过Phonegap online build从我的vanilla Js代码生成一个android应用程序,其中包含一个firebase实时数据库,除了firebase facebook/Google auth之外,其他一切都可以正常工作 当我点击facebook登录img时,我得到了众所周知的location.protocol错误。使用GoogleAuth时,错误消息是“未安装通用链接插件” firebase docs()说明“firebase Auth取决于deviceReady事件,以便正确确定当前Cordova环境。确保触发该事件后初始化firebase应用程序实例。” 这到底是什么意思?在deviceready事件后调用firebase.initializeApp()函数?不幸的是,我的应用程序从代码一开始就需要firebase应用程序。(deviceready事件触发,admob插件在deviceready事件后启动,并且工作正常。) 有人能给我看一个deviceReady事件firebase应用程序启动的工作示例吗?:)Javascript Firebase身份验证、phonegap构建和deviceready事件,javascript,firebase,firebase-authentication,phonegap,Javascript,Firebase,Firebase Authentication,Phonegap,我想通过Phonegap online build从我的vanilla Js代码生成一个android应用程序,其中包含一个firebase实时数据库,除了firebase facebook/Google auth之外,其他一切都可以正常工作 当我点击facebook登录img时,我得到了众所周知的location.protocol错误。使用GoogleAuth时,错误消息是“未安装通用链接插件” firebase docs()说明“firebase Auth取决于deviceReady事件,以
将firebase添加到设备就绪事件上的项目后,请使用以下代码
var firebaseConfig = {
apiKey: "***********8",
authDomain: "*********.firebaseapp.com",
databaseURL: "https://*********.firebaseio.com",
projectId: "*********8",
storageBucket: "",
messagingSenderId: "000000000000",
appId: "1:0000000000:web:a0a0a0a0a0a0a0a0"
};
// Initialize Firebase
if(!firebase.apps.length){
firebase.initializeApp(firebaseConfig);
}
这就是firebase初始化的方式。是否将上述代码放入设备就绪状态取决于firebase在应用程序中的访问方式
如果universal links标记没有将数据复制到android上的清单文件中,请按照此处的说明进行操作,然后返回此处
我正在使用PhoneGap构建。问题是通用链接标记没有复制到AndroidManifest.xml。所以解决办法是
xmlns:android="http://schemas.android.com/apk/res/android"
在config.xml中的任意位置添加以下代码我更喜欢在插件之前或unvirsal links标签旁边
<config-file target="AndroidManifest.xml" parent="/manifest/application/activity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="****-***.firebaseapp.com" android:pathPrefix="/__/auth/callback" android:scheme="https" />
</intent-filter>
</config-file>
现在,当使用phonegapbuild或本地cordova CLI构建应用程序时,它会复制应该在清单文件中的通用链接数据。当应用程序运行并调用firebase.auth().getRedirectResult()时,它不会给出任何类似的错误
用户已验证/取消。用户在完成之前取消了重定向
使用cordova CLI的用户构建应用程序运行cordova build android后,请确保在清单文件的活动标记下有上述意图过滤器标记。你救了我的命,伙计!它终于起作用了。非常感谢你。
<config-file target="AndroidManifest.xml" parent="/manifest/application/activity">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="****-***.firebaseapp.com" android:pathPrefix="/__/auth/callback" android:scheme="https" />
</intent-filter>
</config-file>