Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit72bb39e

Browse files
committed
Added example for cloud messaging.
1 parent72fb881 commit72bb39e

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// Copyright 2015 Google Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// FirebaseCloudMessaging_Send_ESP8266 is a sample that shows sending
18+
// messages to firebase.
19+
20+
#include<ESP8266WiFi.h>
21+
22+
#include<FirebaseCloudMessaging.h>
23+
#include<FirebaseHttpClient.h>
24+
25+
// Set these to run example.
26+
#defineWIFI_SSID"SSID"
27+
#defineWIFI_PASSWORD"PASSWORD"
28+
29+
#defineSERVER_KEY"key_from_dashboard"
30+
#defineCLIENT_REGISTRATION_ID"key_from_client_after_registration"
31+
32+
voidsetup() {
33+
Serial.begin(9600);
34+
35+
// connect to wifi.
36+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
37+
Serial.print("connecting");
38+
while (WiFi.status() != WL_CONNECTED) {
39+
Serial.print(".");
40+
delay(500);
41+
}
42+
Serial.println();
43+
Serial.print("connected:");
44+
Serial.println(WiFi.localIP());
45+
46+
FirebaseCloudMessagingfcm(SERVER_KEY);
47+
FirebaseCloudMessage message =
48+
FirebaseCloudMessage::SimpleNotification("Hello World!","What's happening?");
49+
FirebaseError error = fcm.SendMessageToUser(CLIENT_REGISTRATION_ID, message);
50+
if (error) {
51+
Serial.print("Error:");
52+
Serial.print(error.code());
53+
Serial.print(" ::");
54+
Serial.println(error.message().c_str());
55+
}else {
56+
Serial.println("Sent OK!");
57+
}
58+
}
59+
60+
voidloop() {
61+
}
62+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp