多个设备之间的通讯

时间:2019-02-24 06:57:17

标签: ios firebase push-notification flutter firebase-cloud-messaging

我想申请回合制。这样相关的用户将执行一些操作,并且当他们的交接结束时,下一个用户应该会收到通知。

现在,我将显示标准消息,例如“轮到您了”。因此,我该如何从我的设备触发此通知并弹出“本地保存”的通知。

我做了一些研究,发现了Firebase云消息传递,Firebase推送通知等各种选项。但是对于Firebase推送通知,我们需要一台额外的服务器。我需要为此专门部署服务器吗?

我可以为此使用FCM吗? 任何帮助或参考将不胜感激。

1 个答案:

答案 0 :(得分:0)

我不知道您是否针对此(在线)基于回合的应用程序使用任何数据库。使用Firebase云功能来触发Firebase通知会很容易。 Check this link 您可以在数据库假设中创建一个值,并根据哪个用户的数据来更新数据库中的值。每次使用export class LineChart extends React.Component { state = { graph: null, circles: null, xScale: d3.scaleTime().range([margin.left, width - margin.right]), yScale: d3.scaleLinear().range([height - margin.bottom, margin.top]), lineGenerator: d3.line()//.curve(d3.curveNatural) } xAxis = d3 .axisBottom() .scale(this.state.xScale) .tickFormat(d3.timeFormat('%d.%m.%y')) yAxis = d3 .axisLeft() .scale(this.state.yScale) .tickFormat(d => d) static getDerivedStateFromProps(nextProps, prevState) { if (!nextProps.data) return null const { data } = nextProps const { xScale, yScale, lineGenerator } = prevState xScale.domain(d3.extent(data, d => d.x)) yScale.domain(d3.extent(data, d => d.y)) lineGenerator.x(d => xScale(d.x)) lineGenerator.y(d => yScale(d.y)) const graph = lineGenerator(data) return { graph } } componentDidMount(): void { this._applyAxes() } componentDidUpdate(): void { this._applyAxes() } _applyAxes = (): void => { d3.select(this.refs.xAxis).call(this.xAxis) d3.select(this.refs.yAxis).call(this.yAxis) d3.select(this.refs.xGrid).call( d3 .axisBottom(this.state.xScale) .ticks(10) .tickSize(-height) .tickFormat('') ) d3.select(this.refs.yGrid).call( d3 .axisLeft(this.state.yScale) .ticks(10) .tickSize(-width) .tickFormat('') ) } render() { const { data } = this.props const { graph, xScale, yScale } = this.state return ( <svg width={width} height={height} className={styles.svg}> <path d={graph} className={styles.path} /> {data.map((item, index) => { return ( <circle key={index} r={5} cx={xScale(item.x)} cy={yScale(item.y)} className={styles.dot} /> ) })} <g> <g ref="xGrid" className={styles.grid} transform={`translate(0, ${height})`} /> <g ref="yGrid" className={styles.grid} /> </g> <g> <g ref="xAxis" transform={`translate(0, ${height - margin.bottom})`} /> <g ref="yAxis" transform={`translate(${margin.left}, 0)`} /> </g> </svg> )} } ,您都可以触发并向用户发送通知。为了向特定用户发送通知,您必须将其令牌保存在数据库中。

相关问题