Я пытаюсь инициализировать приложение Firebase в своем приложении Cordova.Но когда я запускаю приложение в эмуляторе ios, оно не может загрузить экземпляр firebase и, следовательно, я не могу получить доступ к apis firebase для подключения к базе данных в реальном времени.Ниже приведен мой config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget id="services.hub" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloWorld</name>
<description>
A sample Apache Cordova application
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<universal-links>
<host name="dsdss" scheme="https" />
<host name="sdasdsa" scheme="https">
<path url="/__/auth/callback" />
</host>
</universal-links>
<plugin name="cordova-plugin-whitelist" spec="1" />
<allow-intent href="*" />
<allow-navigation href="*" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<plugin name="cordova-plugin-buildinfo" spec="2.0.2" />
<plugin name="cordova-universal-links-plugin" spec="~1.2.1" />
<plugin name="cordova-plugin-browsertab" spec="0.2.0" />
<plugin name="cordova-plugin-customurlscheme" spec="4.3.0">
<variable name="URL_SCHEME" value="services.hub" />
</plugin>
<plugin name="cordova-plugin-inappbrowser" spec="3.0.0" />
<engine name="ios" spec="^4.5.5" />
</widget>
My Index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script
src="https://www.gstatic.com/firebasejs/4.2.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.2.0/firebase-auth.js"></script>
<script>
"use strict";
// Show errors to user.
window.onerror = function(msg, url, line, col, error) {
var msgFull = "Error: " + msg + "\nurl: " + url + "\nline: " + line;
alert(msgFull);
};
// Initialize Firebase
var config = {
apiKey: "dcsdcdscsdc",
authDomain: "dsadasd",
databaseURL: "saasdsda",
projectId: "dcssca",
storageBucket: "",
messagingSenderId: "132122"
};
firebase.initializeApp(config);
console.log("Initializing firebase from script tag");
console.log(firebase);
</script>
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>Firebase Testing</h1>
<div>
<input id="emailid" type="email"/>
</div>
<div>
<input id="password" type="password"/>
</div>
<button onclick="login()">Login</button>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
Фрагмент кода JavaScript:
var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
// deviceready Event Handler
//
// Bind any cordova events here. Common events are:
// 'pause', 'resume', etc.
onDeviceReady: function() {
this.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
console.log('Device is ready');
try{
if(firebase){
console.log('Firebase Initialized: ');
}else{
console.log('Firebase NOT VAILABLE');
}
}catch(error){
console.log(error.message);
}
}
};
Когда я запускаю приложение, оно всегдаидет к блоку catch и всегда выдает ошибку "экземпляр firebase не найден"
Я скачал plist-файл и тоже поместил в папку.Не уверен, почему экземпляр firebase не найден.