Dra*_*d83 5 javascript android cordova firebase
我正在构建一个应用程序,使用聚合物入门套件和cordova来包装项目.现在,由于我使用firebase作为存储数据的数据库,我最终使用两个本机firebase javascript函数来查找用户数据:
getAuth()
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
var authData = ref.getAuth();
if (authData) {
console.log("Authenticated user with uid:", authData.uid);
}
Run Code Online (Sandbox Code Playgroud)
onAuth()
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.onAuth(function(authData) {
if (authData) {
console.log("Authenticated with uid:", authData.uid);
} else {
console.log("Client unauthenticated.")
}
});
Run Code Online (Sandbox Code Playgroud)
这两个函数需要重新加载才能从firebase返回数据,但是:
window.location.reload();
Run Code Online (Sandbox Code Playgroud)
不起作用
Alos寻找一个Cordova插件:webview-reloader,安装它但重定向和重新加载仍然无法正常工作.
当我使用reload()函数时,我的Android手机的屏幕变白了,应用程序停止工作.需要关闭应用程序并再次打开它.
Hge*_*sen 18
由于Cordova是浏览器窗口的包装器:
window.location.reload(true);
Run Code Online (Sandbox Code Playgroud)
它适用于浏览器窗口以及Cordova应用程序.
这适用于iOS和Android(至少适用于2016年平台版本)。
// keep startup url (in case your app is an SPA with html5 url routing)
var initialHref = window.location.href;
function restartApplication() {
// Show splash screen (useful if your app takes time to load)
navigator.splashscreen.show();
// Reload original app url (ie your index.html file)
window.location = initialHref;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19810 次 |
| 最近记录: |