答案 0 :(得分:13)
消息传递示例
npm install -g firebase-tools
(如果失败,可能需要sudo
)。firebase login
。这将打开您的浏览器并让您登录到您的Google帐户。git clone https://github.com/firebase/quickstart-js.git
cd quickstart-js
Create new project
Add Firebase to your web application
并复制提示给您的javascript代码。index.html
文件夹中打开messaging
,在第83行打开从信息中心复制的代码。在firebase init
文件夹中输入命令messaging
,然后回答将要问你的问题:
What Firebase CLI features do you want to setup for this folder?
--> Hosting: Configure and deploy Firebase Hosting sites
What file should be used for Database Rules?
--> Blank, it is not relevant for this example.
What do you want to use as your public directory? (public)
--> .
Configure as a single-page app (rewrite all urls to /index.html)?
--> y
File ./index.html already exists. Overwrite?
--> N
输入命令firebase serve -p 8081
(或您拥有的任何其他空闲端口)
Request permission
(如果操作成功,则会显示注册令牌)输入
curl -X POST -H "Authorization: key=YOUR-SERVER-KEY" -H "Content-Type:
application/json" -d '{
"notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1",
"icon": "firebase-icon.png",
"click_action": "http://localhost:8081"
},
"to": "YOUR-IID-TOKEN"
}' "https://fcm.googleapis.com/fcm/send"
使用复制的服务器密钥替换YOUR-SERVER-KEY
,并在点击YOUR-IID-TOKEN
后使用here字符串Request permission
替换Received message:
{
"from": "xxxxxxxxxx",
"collapse_key": "do_not_collapse",
"notification": {
"title": "Portugal vs. Denmark",
"body": "5 to 1",
"icon": "firebase-icon.png",
"click_action": "http://localhost:8081"
}
}
。如果一切都正确完成,则会以local page的形式显示通知
firebase init
数据库示例
您无需运行firebase.json
,因为head
文件已存在并已在存储库中配置。
但如果你想使用它,你必须:
index.html
页的quickstart-js/database
部分粘贴您的凭据(与上一步骤7相同)。firebase serve
文件夹类型命令Sign in with Google
中,应用程序将加载到this page。 firebase init
,输入您的凭证,然后享受它! : - )验证示例
您无需运行firebase.json
,因为facebook-credentials.html
文件已存在并已在存储库中配置。
要使用它(我没有尝试过),例如你应该:
head
部分的script
<YOUR_FACEBOOK_APP_ID>
部分粘贴quickstart-js/auth
firebase serve
命令Facebook Login using OAuth Credentials (via Facebook Login Button)
,应用程序将加载到this page。facebook-popup.html
登录。如果您想使用其他方法,则必须以相同的方式修改相应的文件(facebook-redirect
,#include "stdafx.h"
#include <iostream>
using namespace std;
class Ec {
public: float a, b; //equation's parameters
public:
Ec() {float x, y; cout <<"a= "; cin >> x; cout << "b= ";
cin >> y; a = x; b = y; cout << "void constr\n";};
Ec(float x, float y) { a = x; b = y; cout << "param constr\n"; }
~Ec() { cout << "destr\n"; }
Ec(Ec &z) { a = z.a; b = z.b; cout << "cpy constr\n"; }
friend float half1(Ec); //function to return a/2
friend float half2(Ec); //function to return b/2
friend float sol1(Ec); //function to return the solution for the standard eq
friend float sol2(Ec); //function to return the sol for the /2 param eq
};
float half1(Ec ec1) { return (ec1.a / 2);}
float half2(Ec ec1) { return (ec1.b / 2); }
float sol1(Ec ec1) { float x; return x = -ec1.b / ec1.a; }
float sol2(Ec ec1) { float x2; return x2 = -half2(ec1) / half1(ec1); }
int main()
{
int x, y;
cout << "a= ";
cin >> x;
cout << "b= ";
cin >> y;
Ec ec1;
Ec ec2(x, y);
Ec ec3 = ec1;
//the couts display for ex:" ec 2x+1=0 has sol -0.5"
cout << "ec " << ec1.a << "x+ " << ec1.b << "=0 has sol " << sol1(ec1) << endl;
cout << "ec " << ec2.a << "x+ " << ec2.b << "=0 has sol " << sol1(ec2) << endl;
cout << "ec " << ec3.a << "x+ " << ec3.b << "=0 has sol " << sol1(ec3) << endl;
cout << "ec halved " << half1(ec1) << "x+ " << half2(ec1) << "=0 has sol " << sol2(ec1) << endl;
cout << "ec halved " << half1(ec2) << "x+ " << half2(ec2) << "=0 has sol " << sol2(ec2) << endl;
cout << "ec halved " << half1(ec3) << "x+ " << half2(ec3) << "=0 has sol " << sol2(ec3) << endl;
}
return 0;
}
等。)
随意询问是否不清楚。