我正在尝试使用AngularFire2从我的Firebase获取数据.我想查看具体数据,在从Firebase获取此数据后,我只能在特定范围内检查,而不是在对Firebase进行操作后检查.为什么会这样?
以下是我的代码:
this.af.database.list('/users/1qfcMAQnglX9jsW5GdLpPko1HqE2', { preserveSnapshot: true})
.subscribe(snapshots=>{
snapshots.forEach(snapshot => {
if(snapshot.key=="reg_boolean"){
console.log(snapshot.val());
this.bo=snapshot.val();
}
this.currentUser.push({key:snapshot.key,value:snapshot.val()});
console.log(this.currentUser);
//console.log(snapshot.key, snapshot.val());
if(this.bo==true){console.log("happy"); }; //i can access only in this scope
});
})
if(this.bo==true){console.log("happy"); }; //why i can access this value??it's undefined, this happen before the subscribe with angularfire2
Run Code Online (Sandbox Code Playgroud)
我在我的react-native v0.49应用程序上实现了检查互联网.我正在使用反应原生的NetInfo.我在发生任何更改时添加了eventListener,它将调用函数.但是当我在模拟器和真实设备中进行测试时,我只得到第一个更改,但如果我从Wifi断开连接,我看不到任何变化.
internetConnectionPopUp
import React, { Component } from 'react';
import {
View,
Text,
NetInfo
} from 'react-native';
// styles
import { style } from './style';
import { globalStyle } from '../../assets/styles/globalStyle';
// redux
import {connect} from 'react-redux';
import * as actions from '../../actions';
class InternetConnectionPopUp extends Component {
constructor(props){
super(props);
this.state = {
connectionInfo : ''
}
this.handleFirstConnectivityChange = this.handleFirstConnectivityChange.bind(this);
}
handleFirstConnectivityChange(connectionInfo) {
this.setState({
connectionInfo: connectionInfo.type
})
console.log('First change, type: ' + connectionInfo.type + ', effectiveType: ' + connectionInfo.effectiveType); …Run Code Online (Sandbox Code Playgroud) 我已经对我在笔记本电脑上工作的本地项目做出了反应。当我将项目转移到我的PC并运行yarn安装时(我使用yarn安装了一些模块,使用npm安装了一些模块)
发生意外错误:“ https://registry.yarnpkg.com/jest/-/jest-23.0.0-alpha.0.tgz:请求失败“找不到404”。
我的PC和Latop上的纱线版本相同
1.5.1
Run Code Online (Sandbox Code Playgroud)
NPM版本我的电脑和笔记本电脑相同
5.4.1
Run Code Online (Sandbox Code Playgroud)
节点版本
v 7.9.0
Run Code Online (Sandbox Code Playgroud)
另外,在我的项目上运行yarn安装时,我会收到警告
warning You are using Node "7.9.0" which is not supported and may encounter bugs or unexpected behavior. Yarn supports the following semver range: "^4.8.0 || ^5.7.0 || ^6.2.2 || >=8.0.0"
Run Code Online (Sandbox Code Playgroud) 我构建了一个 Firebase 云函数,用于查找 'IsNotificationEnabled' 值等于 true 的用户。我的功能的一部分
export const sendPushNotification = functions.https
.onRequest(async (req, res) => {
try {
const { message } = req.body;
var usersRef = firebase.ref('/Users');
var usersPushNotificationTokensRef = firebase.ref('/PushNotificationTokens')
var listUsersSendNotifications = [],
usersWithTokenSendNotifications = [],
promises = [];
if (message) {
await usersRef.orderByChild('IsNotificationEnabled').equalTo(true).once('value', (snapshot) => {
snapshot.forEach((childSnapshot) => {
console.log(childSnapshot.key)
listUsersSendNotifications.push(childSnapshot.key)
return false;
})
})
..........................
Run Code Online (Sandbox Code Playgroud)
正如您在这里看到的,我正在寻找 IsNotificationEnabled = true 的用户。当我运行它时,我进入日志
[2018-05-22T09:12:57.352Z] @firebase/database: FIREBASE 警告:使用未指定的索引。您的数据将在客户端下载和过滤。考虑将 /Users 处的 ".indexOn": "IsNotificationEnabled" 添加到您的安全规则以获得更好的性能。
我在 firebase 控制台中插入的规则
{
"rules": …Run Code Online (Sandbox Code Playgroud) javascript firebase firebase-realtime-database google-cloud-functions
我正在寻找一种方法来制作项目后的动画平面列表项目.当一个项目完成动画时,下一个项目(来自平面列表)将出现在屏幕上
class AnimatedFlatList extends React.PureComponent {
state = {selected: (new Map(): Map<string, boolean>)};
let data = {[
{"first_name":"ltorrejon0@si.edu"},
{"first_name":"ichadbourne1@icq.com"},
{"first_name":"ascorthorne2@mediafire.com"},
{"first_name":"jlathwood3@xing.com"},
{"first_name":"molkowicz4@ftc.gov"},
{"first_name":"motridge5@tiny.cc"},
{"first_name":"rcess6@hostgator.com"},
{"first_name":"mmaundrell7@php.net"},
{"first_name":"ufairburne8@instagram.com"},
{"first_name":"pangel9@biglobe.ne.jp"}]
};
_keyExtractor = (item, index) => item.id;
_onPressItem = (id: string) => {
// updater functions are preferred for transactional updates
this.setState((state) => {
// copy the map rather than modifying state.
const selected = new Map(state.selected);
selected.set(id, !selected.get(id)); // toggle
return {selected};
});
};
_renderItem = (item) => (
<View style={Styles.viewItem}}>
<Text …Run Code Online (Sandbox Code Playgroud) 我将cli更新为离子3版本,当我运行时
离子cordova运行android
构建apk文件并在android模拟器中运行我收到此错误
C:\Users\XXXX\Desktop\beep>ionic cordova run android
Running app-scripts build: --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser
[20:52:20] build dev started ...
[20:52:20] clean started ...
[20:52:20] clean finished in 11 ms
[20:52:20] copy started ...
[20:52:20] transpile started ...
[20:52:22] transpile finished in 2.53 s
[20:52:22] preprocess started ...
[20:52:22] deeplinks started ...
[20:52:23] deeplinks finished in 52 ms
[20:52:23] preprocess finished in 54 ms
[20:52:23] webpack started ...
[20:52:23] copy finished in …Run Code Online (Sandbox Code Playgroud) 我打开了一个 Angular 4 项目,购买了 html 和 js 模板,我想让它一起工作,以便在我编写的样式下进入 angular-cli.json
\n\n "styles": [\n "../node_modules/bootstrap/dist/css/bootstrap.css",\n "../node_modules/perfect-scrollbar/css/perfect-scrollbar.css",\n "./assets/sass/material-dashboard.scss",\n "./assets/css/demo.css",\n "./assets/fonts/fonts.css",\n "./assets/stylesheets/ionicons.min",\n "./assets/stylesheets/fonts/fonts.css",\n "./assets/stylesheets/bootstrap.css",\n "./assets/stylesheets/isotope.css",\n "./assets/stylesheets/venobox.css",\n "./assets/stylesheets/slimmenu.css",\n "./assets/stylesheets/main.css",\n "./assets/stylesheets/main-bg.css",\n "./assets/stylesheets/main-responsive.css"\n ],\nRun Code Online (Sandbox Code Playgroud)\n\njavascript
\n\n "scripts": [\n "../node_modules/jquery/dist/jquery.js",\n "../node_modules/bootstrap/dist/js/bootstrap.js",\n "../node_modules/bootstrap-material-design/dist/js/ripples.min.js",\n "../node_modules/bootstrap-material-design/dist/js/material.min.js",\n "../node_modules/arrive/src/arrive.js",\n "../node_modules/moment/moment.js",\n "../node_modules/perfect-scrollbar/dist/perfect-scrollbar.min.js",\n "../node_modules/bootstrap-notify/bootstrap-notify.js",\n "../node_modules/chartist/dist/chartist.js",\n "./assets/javascripts/libs/common.js",\n "./assets/javascripts/libs/bootstrap.min.js",\n "./assets/javascripts/custom/main.js"\n ],\nRun Code Online (Sandbox Code Playgroud)\n\n我的角度 cli
\n\n{\n"$schema": "./node_modules/@angular/cli/lib/config/schema.json",\n"project": {\n "name": "material-dashboard-angular"\n},\n"apps": [{\n "root": "src",\n "outDir": "dist",\n "assets": [\n "assets",\n "favicon.ico"\n ],\n "index": "index.html",\n "main": "main.ts",\n "polyfills": "polyfills.ts",\n "test": "test.ts",\n "tsconfig": "tsconfig.app.json",\n "testTsconfig": "tsconfig.spec.json",\n "prefix": "app",\n "styles": [\n …Run Code Online (Sandbox Code Playgroud) 我正在使用firebase/firestore,我正在寻找一种方法来返回快照的承诺.
onlineUsers(){
// i want to return onSnapshot
return this.status_database_ref.where('state','==','online').onSnapshot();
}
Run Code Online (Sandbox Code Playgroud)
在我做的其他文件中
componentDidMount(){
// this.unsubscribe = this.ref.where('state','==','online').onSnapshot(this.onCollectionUpdate)
firebaseService.onlineUsers().then(e=>{
console.log(e)
})
}
Run Code Online (Sandbox Code Playgroud)
我得到了错误
错误:Query.onSnapshot失败:使用无效参数调用.
TypeError:_firebaseService2.default.unsubscribe不是函数
如果我这样做
onlineUsers(){
return this.status_database_ref.where('state','==','online').onSnapshot((querySnapshot)=>{
return querySnapshot
})
}
Run Code Online (Sandbox Code Playgroud)
我明白了
TypeError: _firebaseService2.default.onlineUsers(...).then is not a function
Run Code Online (Sandbox Code Playgroud)
另外,当我这样做的时候
this.unsubscribe = firebaseService.onlineUsers().then((querySnapshot)=>{
console.log(querySnapshot.size)
this.setState({count:querySnapshot.size})
})
Run Code Online (Sandbox Code Playgroud)
//其他文件
onlineUsers(callback) {
return this.status_database_ref.where('state', '==', 'online').get()
}
Run Code Online (Sandbox Code Playgroud)
它没有听到更改为firebase,意味着如果我更改firebase它不更新或更改大小..
---- firestore函数---我试图使firestore函数在每次UserStatus节点更新时触发,但这需要几秒钟而且对我来说很慢.
module.exports.onUserStatusChanged = functions.database
.ref('/UserStatus/{uid}').onUpdate((change, context) => {
// Get the data written to Realtime Database
const eventStatus = change.after.val();
// Then use other …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用链接到业务页面从 React Native 应用程序打开 Facebook Messenger。我成功地为用户做到了这一点
Linking.openURL(`fb-messenger://user/1000XXXXXXXXX`)
Run Code Online (Sandbox Code Playgroud)
但对于商业页面,例如此页面
我尝试过这种方式
Linking.openURL(`fb-messenger://user//sport24live`)
Run Code Online (Sandbox Code Playgroud)
或者
Linking.openURL(`fb-messenger://sport24live`)
Run Code Online (Sandbox Code Playgroud)
它不起作用,无法打开任何东西。
react-native ×5
firebase ×3
javascript ×3
ionic2 ×2
android ×1
angular ×1
angular-cli ×1
angularfire2 ×1
animation ×1
callback ×1
cordova ×1
css ×1
facebook ×1
ionic3 ×1
ios ×1
node.js ×1
npm ×1
yarnpkg ×1