+
+
+
+
+
+
diff --git a/pages/services/authentication/custom_tokens.md b/pages/services/authentication/custom_tokens.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/authentication/custom_tokens.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/authentication/linking.md b/pages/services/authentication/linking.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/authentication/linking.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/authentication/providers.md b/pages/services/authentication/providers.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/authentication/providers.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/authentication/username.md b/pages/services/authentication/username.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/authentication/username.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/authentication/verification/2fa_verification.md b/pages/services/authentication/verification/2fa_verification.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/authentication/verification/2fa_verification.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/authentication/verification/custom.md b/pages/services/authentication/verification/custom.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/authentication/verification/custom.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/authentication/verification/email_verification.md b/pages/services/authentication/verification/email_verification.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/authentication/verification/email_verification.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/authentication/verification/sms_verification.md b/pages/services/authentication/verification/sms_verification.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/authentication/verification/sms_verification.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/firestore/firestore_reads.md b/pages/services/firestore/firestore_reads.md
new file mode 100644
index 0000000..b2a25ca
--- /dev/null
+++ b/pages/services/firestore/firestore_reads.md
@@ -0,0 +1,114 @@
+
+# Firestore Read Operations
+
+This is an example of reading data from Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Fetching a single document
+{{anchor:Read single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').doc('alovelace').get().then((doc) => {
+ if (doc.exists) {
+ console.log('Document data:', doc.data());
+ } else {
+ console.log('No such document!');
+ }
+}).catch((error) => {
+ console.log('Error getting document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.get().then((doc) => {
+ if (doc.exists) {
+ console.log('Document data:', doc.data());
+ } else {
+ console.log('No such document!');
+ }
+}).catch((error) => {
+ console.log('Error getting document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+doc = doc_ref.get()
+if doc.exists:
+ print(f'Document data: {doc.to_dict()}')
+else:
+ print('No such document!')
+```
+{{endgroup}}
+
+### Fetching multiple documents
+
+{{anchor:Read many documents}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').get().then((querySnapshot) => {
+ querySnapshot.forEach((doc) => {
+ console.log(`${doc.id} => ${doc.data()}`);
+ });
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+db.collection('users').get().then((querySnapshot) => {
+ querySnapshot.forEach((doc) => {
+ console.log(`${doc.id} => ${doc.data()}`);
+ });
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+users_ref = db.collection('users')
+docs = users_ref.stream()
+
+for doc in docs:
+ print(f'{doc.id} => {doc.to_dict()}')
+```
+{{endgroup}}
+
+{{anchor:Warnings}}
+
+> **Warning:** When using Firestore, be aware that querying on multiple fields with different operators can result in performance issues. Always ensure indexes are properly set up to optimize query execution times.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/firestore/firestore_writes.md b/pages/services/firestore/firestore_writes.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/firestore/firestore_writes.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/firestore/placeholder.md b/pages/services/firestore/placeholder.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/firestore/placeholder.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/services/firestore/security_rules/placeholder.md b/pages/services/firestore/security_rules/placeholder.md
new file mode 100644
index 0000000..a2ca277
--- /dev/null
+++ b/pages/services/firestore/security_rules/placeholder.md
@@ -0,0 +1,124 @@
+
+# Firestore Write Operations
+
+This is an example of writing data to Firestore.
+
+## Overview
+
+Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.
+
+## Example Code
+
+### Adding a new document
+
+{{anchor:Write single document}}
+{{group:code}}
+```js
+// JavaScript
+db.collection('users').add({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then((docRef) => {
+ console.log('Document written with ID: ', docRef.id);
+}).catch((error) => {
+ console.error('Error adding document: ', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc();
+
+docRef.set({
+ first: 'Ada',
+ last: 'Lovelace',
+ born: 1815
+}).then(() => {
+ console.log('Document successfully written!');
+}).catch((error) => {
+ console.error('Error writing document: ', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document()
+
+doc_ref.set({
+ 'first': 'Ada',
+ 'last': 'Lovelace',
+ 'born': 1815
+})
+print('Document successfully written!')
+```
+{{endgroup}}
+
+### Updating an existing document
+
+{{anchor:Updating many documents}}
+{{group:code}}
+```js
+// JavaScript
+const userRef = db.collection('users').doc('alovelace');
+
+userRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```node
+// Node.js
+const admin = require('firebase-admin');
+admin.initializeApp();
+
+const db = admin.firestore();
+
+const docRef = db.collection('users').doc('alovelace');
+
+docRef.update({
+ born: 1815
+}).then(() => {
+ console.log('Document successfully updated!');
+}).catch((error) => {
+ console.error('Error updating document:', error);
+});
+```
+```python
+# Python
+import firebase_admin
+from firebase_admin import credentials, firestore
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+
+db = firestore.client()
+
+doc_ref = db.collection('users').document('alovelace')
+
+doc_ref.update({
+ 'born': 1815
+})
+print('Document successfully updated!')
+```
+{{endgroup}}
+
+> **Warning:** When updating documents in Firestore, be aware that large numbers of writes in a short period of time can lead to performance issues. Always ensure your updates are batched or throttled as necessary.
+
+## Comments
+
+Feel free to add comments to your code to make it more readable.
diff --git a/pages/tutorials/firebase/app_features/Account_Linking_Guide.md b/pages/tutorials/firebase/app_features/Account_Linking_Guide.md
new file mode 100644
index 0000000..082da29
--- /dev/null
+++ b/pages/tutorials/firebase/app_features/Account_Linking_Guide.md
@@ -0,0 +1,242 @@
+
+# Comprehensive Guide on Account Linking and Managing Multiple Instances of Authentication in Firebase
+
+## Table of Contents
+1. [Introduction](#introduction)
+2. [Setting Up Firebase Authentication](#setting-up-firebase-authentication)
+3. [Account Linking](#account-linking)
+4. [Master Account Management](#master-account-management)
+5. [Handling Multiple Authentication Instances](#handling-multiple-authentication-instances)
+6. [Sample Implementation](#sample-implementation)
+7. [Security Considerations](#security-considerations)
+8. [Conclusion](#conclusion)
+
+## Introduction
+
+In modern applications, users may want to use multiple authentication methods such as email/password, Google, Facebook, and others. Firebase Authentication provides a simple way to link these different accounts to a single user profile, allowing for a seamless user experience.
+
+## Setting Up Firebase Authentication
+
+Before implementing account linking, ensure you have Firebase Authentication set up in your project.
+
+### Step 1: Create a Firebase Project
+
+1. Go to the [Firebase Console](https://console.firebase.google.com/).
+2. Click "Add project" and follow the setup steps.
+
+### Step 2: Enable Authentication Providers
+
+1. In your Firebase project, navigate to "Authentication" > "Sign-in method".
+2. Enable the desired authentication providers (Email/Password, Google, Facebook, etc.).
+
+### Step 3: Initialize Firebase in Your App
+
+```javascript
+// firebase.js
+import firebase from 'firebase/app';
+import 'firebase/auth';
+
+const firebaseConfig = {
+ apiKey: "YOUR_API_KEY",
+ authDomain: "YOUR_AUTH_DOMAIN",
+ projectId: "YOUR_PROJECT_ID",
+ storageBucket: "YOUR_STORAGE_BUCKET",
+ messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
+ appId: "YOUR_APP_ID"
+};
+
+firebase.initializeApp(firebaseConfig);
+
+export const auth = firebase.auth();
+```
+
+## Account Linking
+
+Account linking allows users to link multiple authentication providers to a single Firebase user. This process ensures that users can sign in with any of their linked accounts.
+
+### Step 1: Sign In with the Primary Account
+
+```javascript
+auth.signInWithEmailAndPassword(email, password)
+ .then((userCredential) => {
+ const user = userCredential.user;
+ // User signed in
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+```
+
+### Step 2: Link an Additional Provider
+
+```javascript
+const provider = new firebase.auth.GoogleAuthProvider();
+
+auth.currentUser.linkWithPopup(provider)
+ .then((result) => {
+ // Accounts successfully linked
+ const credential = result.credential;
+ const user = result.user;
+ console.log('Accounts linked:', user);
+ })
+ .catch((error) => {
+ console.error('Error linking accounts:', error);
+ });
+```
+
+## Master Account Management
+
+A master account is a centralized account that manages multiple authentication instances. This account acts as the root authentication profile for the user.
+
+### Creating a Master Account
+
+1. **Sign Up or Sign In the Master Account**
+
+```javascript
+auth.createUserWithEmailAndPassword(email, password)
+ .then((userCredential) => {
+ const user = userCredential.user;
+ // Master account created
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+```
+
+2. **Link Additional Authentication Methods**
+
+```javascript
+const googleProvider = new firebase.auth.GoogleAuthProvider();
+const facebookProvider = new firebase.auth.FacebookAuthProvider();
+
+auth.currentUser.linkWithPopup(googleProvider)
+ .then((result) => {
+ // Google account linked
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+
+auth.currentUser.linkWithPopup(facebookProvider)
+ .then((result) => {
+ // Facebook account linked
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+```
+
+## Handling Multiple Authentication Instances
+
+When managing multiple authentication instances, it is essential to handle sign-ins, linking, and unlinking correctly.
+
+### Sign In with a Linked Account
+
+```javascript
+const googleProvider = new firebase.auth.GoogleAuthProvider();
+
+auth.signInWithPopup(googleProvider)
+ .then((result) => {
+ const user = result.user;
+ console.log('Signed in with Google:', user);
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+```
+
+### Unlink an Account
+
+```javascript
+auth.currentUser.unlink('google.com')
+ .then(() => {
+ console.log('Google account unlinked');
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+```
+
+### Managing Auth States
+
+Use Firebase Authentication state listeners to manage the user's authentication state across different providers.
+
+```javascript
+auth.onAuthStateChanged((user) => {
+ if (user) {
+ console.log('User is signed in:', user);
+ } else {
+ console.log('No user is signed in');
+ }
+});
+```
+
+## Sample Implementation
+
+Here’s a sample implementation demonstrating account linking, sign-in, and unlinking in a simple React component:
+
+```javascript
+import React, { useState, useEffect } from 'react';
+import { auth } from './firebase';
+
+const AuthManager = () => {
+ const [user, setUser] = useState(null);
+
+ useEffect(() => {
+ const unsubscribe = auth.onAuthStateChanged((user) => {
+ setUser(user);
+ });
+ return unsubscribe;
+ }, []);
+
+ const linkGoogle = () => {
+ const provider = new firebase.auth.GoogleAuthProvider();
+ auth.currentUser.linkWithPopup(provider)
+ .then((result) => {
+ console.log('Google account linked:', result.user);
+ })
+ .catch((error) => {
+ console.error('Error linking Google account:', error);
+ });
+ };
+
+ const unlinkGoogle = () => {
+ auth.currentUser.unlink('google.com')
+ .then(() => {
+ console.log('Google account unlinked');
+ })
+ .catch((error) => {
+ console.error('Error unlinking Google account:', error);
+ });
+ };
+
+ return (
+
+ {user ? (
+
+
Welcome, {user.email}
+
+
+
+
+ ) : (
+
+ )}
+
+ );
+};
+
+export default AuthManager;
+```
+
+## Security Considerations
+
+- **Enforce Security Rules:** Use Firebase security rules to protect user data.
+- **Monitor Linked Accounts:** Regularly monitor linked accounts for unusual activity.
+- **Prompt for Re-authentication:** Require users to re-authenticate before performing sensitive operations, such as linking or unlinking accounts.
+
+## Conclusion
+
+Account linking in Firebase Authentication simplifies the user experience by allowing multiple authentication methods to be linked to a single user profile. By managing a master account, you can centralize authentication and provide a seamless experience for users across different platforms. Implementing this feature requires careful handling of authentication states, linking and unlinking methods, and ensuring robust security practices.
+
+By following this guide, you can effectively implement and manage multiple authentication instances in your Firebase project.
diff --git a/pages/tutorials/firebase/app_features/Public_User_Profiles.md b/pages/tutorials/firebase/app_features/Public_User_Profiles.md
new file mode 100644
index 0000000..7195d2b
--- /dev/null
+++ b/pages/tutorials/firebase/app_features/Public_User_Profiles.md
@@ -0,0 +1,270 @@
+
+# Setting Up Public User Profiles with Firebase and Cloudflare
+
+## Overview
+This guide provides a comprehensive approach to setting up public user profiles using Firebase Realtime Database and Cloudflare. It outlines the necessary steps to configure Firebase, set up security rules, integrate with Cloudflare for caching, and optionally use Firebase Functions for cache invalidation. The guide ensures that user profiles are efficiently fetched and displayed while protecting critical data and optimizing performance.
+
+# Requirements for Setting Up Public User Profiles with Firebase and Cloudflare
+
+## 1. Firebase Project
+- A Firebase account
+- A Firebase project set up in the Firebase Console
+
+## 2. Firebase Realtime Database
+- Initialization and setup of Firebase Realtime Database
+- Security rules to:
+ - Make user profiles public
+ - Prevent score manipulation
+ - Enforce a cooldown period for updates (10 minutes)
+
+## 3. Firebase Functions (Optional)
+- Node.js environment set up
+- Firebase Functions initialized in your Firebase project
+- Axios for handling HTTP requests
+
+## 4. Cloudflare Account
+- A Cloudflare account
+- Site added to Cloudflare
+- DNS settings configured to point your domain’s DNS to Cloudflare’s nameservers
+
+## 5. Cloudflare Configuration
+- Caching level set to "Standard"
+- "Always Online" enabled
+
+## 6. Domain Setup
+- Custom domain linked in Firebase Hosting via Cloudflare
+
+
+## Step 1: Setting Up Firebase Realtime Database
+
+1. **Create a Firebase Project:**
+ - Go to the [Firebase Console](https://console.firebase.google.com/).
+ - Click on "Add project" and follow the steps to create a new project.
+
+2. **Set Up Realtime Database:**
+ - In your Firebase project, navigate to "Realtime Database" in the sidebar.
+ - Click "Create Database" and select a location.
+ - Start in "Test mode" for now to configure the rules.
+
+3. **Set Security Rules:**
+ - Go to the "Rules" tab and set the following rules to make user profiles public, prevent score manipulation, and ensure updates only occur every 10 minutes:
+ ```json
+ {
+ "rules": {
+ "profiles": {
+ ".read": true,
+ ".write": "auth != null",
+ "$uid": {
+ ".write": "auth != null && $uid === auth.uid && (data.child('updated_at').val() == null || data.child('updated_at').val() + 600000 < now)",
+ "score": {
+ ".validate": "newData.val() === data.val()"
+ },
+ "updated_at": {
+ ".validate": "newData.val() === now"
+ }
+ }
+ }
+ }
+ }
+ ```
+
+4. **Adding User Profiles:**
+ - In the "Data" tab, create a structure under `profiles` to store user data:
+ ```json
+ {
+ "profiles": {
+ "uid1": {
+ "name": "John Doe",
+ "email": "john@example.com",
+ "profile_picture": "https://example.com/john.jpg",
+ "country": "USA",
+ "message": "Hello, world!",
+ "score": 100,
+ "updated_at": 1620000000
+ },
+ "uid2": {
+ "name": "Jane Smith",
+ "email": "jane@example.com",
+ "profile_picture": "https://example.com/jane.jpg",
+ "country": "Canada",
+ "message": "Welcome to my profile!",
+ "score": 200,
+ "updated_at": 1620000000
+ }
+ }
+ }
+ ```
+
+## Step 2: Setting Up Cloudflare
+
+1. **Create a Cloudflare Account:**
+ - Go to [Cloudflare](https://www.cloudflare.com/) and create an account.
+ - Add your site to Cloudflare by following the instructions.
+
+2. **Configure DNS Settings:**
+ - Point your domain’s DNS to Cloudflare’s nameservers provided during setup.
+
+3. **Setting Up Caching:**
+ - In Cloudflare dashboard, go to "Caching" > "Configuration".
+ - Set caching level to "Standard" and enable "Always Online".
+
+## Step 3: Implementing Cloud Functions (Optional)
+
+This step is optional as Cloudflare will also expire cache after some time. If you want to ensure immediate cache invalidation, follow these steps:
+
+1. **Set Up Firebase Functions:**
+ - In your Firebase project directory, initialize Firebase Functions:
+ ```bash
+ firebase init functions
+ ```
+
+2. **Install Axios for HTTP Requests:**
+ - Install Axios to handle HTTP requests to Cloudflare:
+ ```bash
+ npm install axios
+ ```
+
+3. **Write the Cloud Function:**
+ - In `functions/index.js`, add the following code to detect profile updates and invalidate cache:
+ ```javascript
+ const functions = require('firebase-functions/v2');
+ const admin = require('firebase-admin');
+ const axios = require('axios');
+
+ admin.initializeApp();
+
+ exports.invalidateCloudflareCache = functions.pubsub.schedule('every 6 hours').onRun(async (context) => {
+ const db = admin.database();
+ const profilesRef = db.ref('profiles');
+ const sixHoursAgo = Date.now() - 6 * 60 * 60 * 1000;
+
+ const snapshot = await profilesRef.orderByChild('updated_at').startAt(sixHoursAgo).once('value');
+
+ if (snapshot.exists()) {
+ const updatedProfiles = snapshot.val();
+ const uids = Object.keys(updatedProfiles);
+
+ for (const uid of uids) {
+ const url = `https://example.com/profiles/${uid}.json`; // Replace with your actual profile URL
+ await axios.post(
+ 'https://api.cloudflare.com/client/v4/zones/YOUR_ZONE_ID/purge_cache', // Replace with your Cloudflare zone ID
+ { files: [url] },
+ {
+ headers: {
+ 'X-Auth-Email': 'YOUR_CLOUDFLARE_EMAIL', // Replace with your Cloudflare account email
+ 'X-Auth-Key': 'YOUR_CLOUDFLARE_API_KEY', // Replace with your Cloudflare API key
+ 'Content-Type': 'application/json'
+ }
+ }
+ );
+ }
+ }
+ });
+ ```
+
+## Step 4: Integrating with Cloudflare
+
+1. **Invalidating Cache:**
+ - The above Cloud Function will automatically invalidate the cache for updated user profiles every 6 hours.
+
+## Step 5: Domain Setup
+
+1. **Link Your Domain:**
+ - In the Firebase Console, go to "Hosting" and click "Add custom domain".
+ - Follow the instructions to link your domain to Firebase Hosting via Cloudflare.
+
+## Step 6: Basic HTML Boilerplate
+
+1. **Create a Simple Web Page:**
+ - In your project, create an `index.html` to display user profiles:
+ ```html
+
+
+
+
+
+ User Profiles
+
+
+
User Profiles
+
+
+
+
+
+ ```
+
+
+## Review and Final thoughts
+
+By following these steps, you can set up public user profiles using Firebase Realtime Database and Cloudflare, ensuring efficient caching and cache invalidation, while protecting critical data like user scores and enforcing a cooldown period for updates. Each user's profile is fetched individually, reducing bandwidth usage and ensuring a better user experience.
+
+
+## Benefits
+
+1. **Scalability:**
+ - Firebase Realtime Database can handle a large number of read and write operations, making it suitable for applications with a growing number of users.
+ - Cloudflare's CDN can distribute content globally, reducing latency for users worldwide.
+
+2. **Performance:**
+ - Caching with Cloudflare reduces the load on Firebase by serving cached content to users, which can significantly improve response times.
+ - The use of a CDN ensures faster data retrieval by serving content from servers closer to the user's location.
+
+3. **Security:**
+ - By using Firebase's security rules, you can ensure that sensitive data (like user scores) cannot be tampered with by clients.
+ - Cloudflare provides additional security features like DDoS protection, which can help safeguard your application from attacks.
+
+4. **Cost-Effective:**
+ - Reducing the number of direct reads from Firebase through caching can lower your database costs, as Firebase charges based on the number of read/write operations.
+ - Cloudflare's free tier includes a lot of features that can help manage costs for small to medium-sized applications.
+
+## Considerations
+
+1. **Cache Invalidation:**
+ - Cache invalidation is a critical aspect of caching strategies. While Cloudflare will expire caches after a set period, having a Cloud Function to invalidate the cache for frequently updated profiles ensures that users always get the most up-to-date information.
+
+2. **Consistency:**
+ - There might be a slight delay between when data is updated in Firebase and when the updated data is available in the cache. This is generally acceptable, but it's important to consider the implications for your application.
+
+3. **Complexity:**
+ - Introducing a caching layer adds some complexity to your architecture. However, the performance benefits usually outweigh this added complexity.
+ - Ensuring that the server timestamp and cooldown logic are correctly implemented requires careful consideration of edge cases.
+
+## Recommendations
+
+1. **Monitor and Adjust Cache Settings:**
+ - Regularly monitor the cache hit rate and adjust the cache expiration settings based on the usage patterns of your application.
+ - Use Cloudflare analytics to understand how often the cache is hit and how often it is bypassed.
+
+2. **Optimize Security Rules:**
+ - Continuously review and optimize your Firebase security rules to ensure they are as restrictive as possible while still allowing the necessary operations.
+
+3. **Load Testing:**
+ - Perform load testing to ensure that your Firebase database and Cloudflare configuration can handle the expected load, especially during peak usage times.
+
+4. **Documentation and Maintenance:**
+ - Keep thorough documentation of your setup, including the reasons for specific configurations. This will help in maintaining and scaling the system in the future.
+
+## Conclusion
+
+This approach is robust and leverages the strengths of both Firebase and Cloudflare to create a scalable, performant, and secure solution for serving public user profiles. By combining real-time data with effective caching strategies, you can ensure that users have a fast and reliable experience when accessing profiles.
diff --git a/pages/tutorials/firebase/firestore/design with firestore.md b/pages/tutorials/firebase/firestore/design with firestore.md
new file mode 100644
index 0000000..ba3d2e0
--- /dev/null
+++ b/pages/tutorials/firebase/firestore/design with firestore.md
@@ -0,0 +1,96 @@
+Cloud Firestore is Google's massively scalable, serverless, NoSQL "document-store" database. Many people use Firestore as part of a Firebase project.
+
+Firestore is really a system of storing Documents. A Document is a "set of key-value pairs", by which you can think of a "JSON Object" or a "Map":
+
+{
+ name: "Fred Flintstone",
+ age: 42,
+ favoriteFoods: [ "Bronto Burgers", "Dino Eggs" ],
+ spouse: {
+ name: "Wilma Flintstone",
+ hairColor: "red"
+ }
+}
+How to design the structure of your Firestore database (or any document-store database) is a mixture of science and art.
+
+Consider your app's Details screens
+One main rule of thumb is to put "all the data you need" for each of your app's "Details screens" into a document. If you go to the User Details screen, have the data you will show on that screen in the "User" document. Same for the Toolbox Details screen -- put all the data you need into a "Toolbox" document. You can decide if it makes sense to have a Tool Details screen and a separate collection of "Tools" documents, or if the data for each Tool is simple enough to just put that data into a field within the Toolbox document (e.g. a tools array field).
+
+A Firestore document is limited to 1MB in size. That is sufficient to store the text of a 3-volume book set (think: all 3 books of Lord Of The Rings). You likely don't want to get too close to the 1MB limit for fear that some documents might over time grow to beyond that point (and then you have to restructure things). On the flip side, you don't want millions of documents containing just a couple of string or number values in them.
+
+Unlearn SQL -- avoid JOINS
+Another rule-of-thumb is to avoid doing "JOINS". Most document-store databases are not good dealing with "following references" -- doing so in Firestore involves multiple queries. Instead of "normalizing data" to individual documents, take advantage of "de-normalization" (i.e. data DUPLICATION) across multiple documents in support of the previous rule-of-thumb (i.e. "all the data you need in one document").
+
+For example, I have a collection of "Players" where each document contains all the data that I show on the "Player Details" screen. I also have a collection of "Teams" where each document contains all the information that I show on the "Team Details" screen including SOME information about the players on the team. So in my Team document I have a players array that contains a DUPLICATION of the data in each of the Player documents. I do not simply reference the Player document IDs which would force me to make multiple READ calls to show the data on my "Team Details" screen.
+
+Querying Arrays-of-Objects
+One limitation of Firestore is the ability to query an array-of-objects. For example, in my Team documents I have a field named players that is an array of objects:
+
+players: [
+ { playerId: 1111, name: "Fred", email: "fred@test.com" },
+ { playerId: 2222, name: "Barney", email: "barney@test.com" }
+]
+Firestore allows querying an array-of-objects, but only for exact matches of the object. If I want to find all Team documents that have Barney on them, I need to query:
+
+query(
+ collection(db, "Team"),
+ where("players", "array-contains",
+ '{ playerId: 2222, name: "Barney", email: "barney@test.com" }'
+ )
+)
+Notice that I am required to specify all of the object values -- I cannot find all Team documents that have playerId == 2222.
+
+To find all Team documents that have playerId. . . one approach is to add another array field to the Team documents that contains just the playerId values from the players array. There is a bit of overhead maintaining this array, but not having it means you can't do the search your app needs:
+
+query(
+ collection(db, "Team"),
+ where("playerIds", "array-contains", 2222)
+)
+You might find yourself maintaining several arrays this way, for example playerIds and emails.
+
+Collections and Subcollections
+Firestore is a system for storing Documents. Each Document has a path that comprises a Document ID and a path prefix . That prefix is referred to as a Collection.
+
+Note that Firestore only stores Documents . Collections (and subcollections) don't really exist, at least not as objects inside Firestore. A Collection is the set of Documents that have the same path prefix.
+
+A path in Firestore comprises one or more segments. For example, /user/1111 is a path with 2 segments: the collection user and the document ID 1111.
+
+Notes about Collections:
+
+You do not create a Collection.
+
+There is no API for creating a Collection.
+
+Collections do not exist. Only their child Documents exist.
+
+Only Documents exist in Firestore.
+
+A Subcollection is a collection whose path has three or more segments: /user/1111/reviews is a subcollection named reviews .
+
+Notes about Subcollections:
+
+Same notes as Collections.
+
+The "parent Document" (e.g. /user/1111) does not need to exist. Only their child Documents need to exist.
+
+One last thing to note about Collections: in the Firestore API a CollectionReference is actually a type of Query. That is, Collections are a way of grouping Documents to enable and simplify fetching data from your database.
+
+Choosing between Collections and Subcollections
+Deciding whether to create a Document at a root Collection or as a Subcollection to some other Document really comes down to thinking about your application, the queries your "Details screens" are going to use, and any reports/analytics questions you are going to ask of your data.
+
+Firestore supports massive scale. A Collection can hold billions of Documents. So choosing a Collection vs. a Subcollection is not a performance or scalability decision. It is more a question of your ability to query the data you need across the Documents.
+
+Things to consider:
+
+Queries needed for "List screens" -- preferably a single query() call
+
+Queries needed for "Details screens" -- preferably a single Document fetch
+
+Securing data -- see Firestore Security Rules & Firestore Security Rules Cookbook
+
+Want to Go Deeper?
+[This is not an endorsement; it is merely an observation]
+
+I have not found a lot of online resources for learning Firestore. One resource that I have found useful is Fireship.io , the producers of the Rules Cookbook mentioned above.
+
+I have not signed up for it yet, but I do see that they have an entire course on Firestore Data Modeling.
\ No newline at end of file
diff --git a/pages/tutorials/firebase/firestore/only documents exist.md b/pages/tutorials/firebase/firestore/only documents exist.md
new file mode 100644
index 0000000..eade3f0
--- /dev/null
+++ b/pages/tutorials/firebase/firestore/only documents exist.md
@@ -0,0 +1,110 @@
+I hang around Firebase Developers and Expo Developers a fair amount.
+
+There are no Collections
+Frequently people post questions such as:
+
+"how do I create a subcollection"
+
+"i wanna create another collection (say 'books' or 'movies')"
+
+and they are stumped trying to find the right code to do it.
+
+I empathize with the confusion. Navigating the Firebase documentation has a pretty steep learning curve ("did I see that in Overview? or Fundamentals? or Build? or Reference? or ...?" )
+
+Firestore is a serverless, NoSQL, document-store database.
+
+In Firestore, a Document is data organized as a set of name-value pairs, sometimes referred to as "a JSON object":
+
+{
+ "name": "Fred Flintstone",
+ "age": 45,
+ "favouriteFoods": [
+ "Bronto Burger",
+ "Dino Eggs",
+ "Gravelberry Pie"
+ ]
+}
+
+BUT -- the thing to understand (grok) about Firestore is that it only contains Documents.
+
+Though the documentation and the APIs offer the concept of a "Collection", it is a lie.
+
+Don't let the fact that the Firebase Console "shows Collections" fool you -- that is simply a UI trick. Notice how when you go to make a new Document the UI label is Add Document, but when you do the same for a Collection the UI label is Start Collection ? The UI prompts you for the name of the Collection but then takes you right to adding a Document. And if you don't add the Document...no Collection will show in the UI.
+
+This is because Firestore only contains Documents.
+
+Documents
+A Document in Firestore has 2 key meta properties: id and path
+A Document with a path of /users/123456 has the id of 123456
+To get a DocumentReference to this document, you would use the API:
+
+let myApp = initializeApp(firebaseConfig);
+let myFS = getFirestore(myApp);
+. . . . . .
+let docRef = doc(myFS, '/users/123456');
+(You will typically initialize the app (myApp) and get the Firestore service instance (myFS) at your app's startup and then use those values throughout the app's lifecycle -- I show one pattern of doing this in this starter React project that uses the Context API with FirebaseProvider.js andAuthProvider.js).
+
+To fetch the data from the above DocumentReference you would use the code:
+
+let docSnap = await getDoc(docRef);
+let theData = docSnap.data();
+(For simplicity here, I'm skipping using try/catch and doing error checking; please don't skip this in your code!)
+
+Note: the call to getDoc() is when your app actually contacts the Firestore service in the cloud (or the Emulator Suite). The API calls of doc() and docSnap.data() do not interact with the Firestore service -- this fact eludes many people and is important for developers in understanding how this system works. For example, you can create a DocumentReference to a path that does not exist: doc(myFS, "this is a jumbled mess") and you won't know that it fails to exist until you go to interact with it, such as calling getDoc() and getting back an empty snapshot.
+
+Collections
+A Collection is actually just "the group of Documents whose path values have the same prefix". For example, all of the Documents whose path begins with "/users" are said to be "in the collection of /users".
+
+To get "all of the Documents in the users collection" you would use the code:
+
+let collRef = collection(myFS, "users");
+let querySnap = await getDocs(collRef);
+if (querySnap.empty) {
+ console.warn("No documents found!");
+ return;
+}
+let theData = querySnap.docs.map( docSnap => docSnap.data() );
+(There are other approaches people take to getting the documents from a querySnapshot, such as also storing the document's ID with the data, but for now the above will suffice).
+
+Notice that what the above code is doing is fetching Documents. You can also build a Query object by adding where(), orderBy() , limit() and other operators to alter the set of Documents you get back from Firestore.
+
+Note: the call to getDocs() is when your app actually contacts the Firestore service in the cloud (or Firebase Emulator Suite). The other API calls above do not contact Firestore.
+
+Subcollections
+Extrapolate the above to the question of "what is a subcollection?"
+
+There are no subcollections in Firestore....or at least, there is no object in Firestore for the Subcollection.
+
+A subcollection in Firestore are all of the Documents whose path has the same prefix, and that prefix has more than one "segment". So, for example, if your Firestore Documents are organized like:
+
+blogPosts << (lvl 1) collection
+ -- 111 << (lvl 2) doc
+ -- commentsForPost << (lvl 3) (sub)collection
+ -- aaa << (lvl 4) doc
+ -- 222 << (lvl 2) doc
+ -- commentsForPost << (lvl 3) (sub)collection
+ -- bbb << (lvl 4) doc
+ -- ccc << (lvl 4) doc
+
+Odd levels are collections.
+Even levels are documents.
+then we say that your Firestore database has 5 Documents (111, 222, aaa, bbb, ccc) that are in 3 "collections" (1 root collection and 2 subcollections):
+
+blogPosts
+
+blogPosts/111/commentsForPost
+
+blogPosts/222/commentsForPost
+
+References -- Fancy Strings
+When creating a DocumentReference, the number of segments (the path separator is "/") must be even. When creating a CollectionReference, the number of segments must be odd.
+
+We often see people writing code such as:
+
+doc(collection(doc(collection(myFS, "blogPosts"), "111"), "commentsForPost"), "aaa")
+
+(or in the older v8 syntax it would have been: myFS.collection("blogPosts).doc("111").collection("commentsForPost").doc("aaa") )
+
+Notice that this code simply creates a DocumentReference. You can simplify this code to: doc(myFS, "blogPosts/111/commentsForPost/aaa")
+
+Again, the API here does not actually contact the Firestore service. You are simply creating a "reference" -- a fancy way of encapsulating that string value so that you can use it with other parts of the Firestore API such as when calling getDoc() , addDoc() , setDoc() , updateDoc() , or deleteDoc() .
\ No newline at end of file
diff --git a/pages/tutorials/flutter/Cloud_Messaging.md b/pages/tutorials/flutter/Cloud_Messaging.md
new file mode 100644
index 0000000..5bfbfac
--- /dev/null
+++ b/pages/tutorials/flutter/Cloud_Messaging.md
@@ -0,0 +1,112 @@
+
+# Firebase Cloud Messaging with Flutter
+
+## Step 1: Add Firebase to Your Flutter Project
+
+First, add the necessary Firebase dependencies to your `pubspec.yaml` file:
+
+```yaml
+dependencies:
+ firebase_core: latest_version
+ firebase_messaging: latest_version
+```
+
+Then, run `flutter pub get` to install these dependencies.
+
+## Step 2: Initialize Firebase in Your App
+
+Initialize Firebase in your Flutter app. This is usually done in the `main.dart` file.
+
+```dart
+// main.dart
+import 'package:flutter/material.dart';
+import 'package:firebase_core/firebase_core.dart';
+import 'package:firebase_messaging/firebase_messaging.dart';
+
+Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
+ await Firebase.initializeApp();
+ print("Handling a background message: ${message.messageId}");
+}
+
+void main() async {
+ WidgetsFlutterBinding.ensureInitialized();
+ await Firebase.initializeApp();
+ FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
+
+ runApp(MyApp());
+}
+
+class MyApp extends StatelessWidget {
+ @override
+ Widget build(BuildContext context) {
+ return MaterialApp(
+ home: Scaffold(
+ appBar: AppBar(title: Text('Firebase Cloud Messaging with Flutter')),
+ body: Center(child: Text('Flutter Firebase Messaging')),
+ ),
+ );
+ }
+}
+```
+
+## Step 3: Request Permission to Show Notifications
+
+In your main Flutter widget, request permission from the user to show notifications.
+
+```dart
+// main.dart (continued)
+class MyApp extends StatefulWidget {
+ @override
+ _MyAppState createState() => _MyAppState();
+}
+
+class _MyAppState extends State {
+ @override
+ void initState() {
+ super.initState();
+
+ FirebaseMessaging.instance.requestPermission(
+ alert: true,
+ announcement: false,
+ badge: true,
+ carPlay: false,
+ criticalAlert: false,
+ provisional: false,
+ sound: true,
+ );
+
+ FirebaseMessaging.instance.getToken().then((String? token) {
+ assert(token != null);
+ print("FCM Token: $token");
+ // Send the token to your server or use it to send notifications
+ });
+
+ FirebaseMessaging.onMessage.listen((RemoteMessage message) {
+ print('Got a message whilst in the foreground!');
+ print('Message data: ${message.data}');
+
+ if (message.notification != null) {
+ print('Message also contained a notification: ${message.notification}');
+ }
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return MaterialApp(
+ home: Scaffold(
+ appBar: AppBar(title: Text('Firebase Cloud Messaging with Flutter')),
+ body: Center(child: Text('Flutter Firebase Messaging')),
+ ),
+ );
+ }
+}
+```
+
+## Step 4: Configure Your Firebase Console
+
+Make sure your Firebase project is correctly set up in the Firebase Console to handle Cloud Messaging.
+
+## Step 5: Deploy and Test
+
+Deploy your Flutter app and test sending notifications from the Firebase Console to ensure that both foreground and background messages are received correctly.
diff --git a/pages/tutorials/ios-swift/Cloud_Messaging.md b/pages/tutorials/ios-swift/Cloud_Messaging.md
new file mode 100644
index 0000000..a6f285b
--- /dev/null
+++ b/pages/tutorials/ios-swift/Cloud_Messaging.md
@@ -0,0 +1,80 @@
+
+# Firebase Cloud Messaging with iOS (Swift)
+
+## Step 1: Add Firebase to Your iOS Project
+
+Add the necessary Firebase dependencies to your `Podfile`.
+
+```ruby
+platform :ios, '10.0'
+
+target 'YourTargetName' do
+ use_frameworks!
+
+ pod 'Firebase/Core'
+ pod 'Firebase/Messaging'
+end
+```
+
+Then, run `pod install` to install these dependencies.
+
+## Step 2: Initialize Firebase in Your App
+
+Initialize Firebase in your iOS app. This is usually done in the `AppDelegate.swift` file.
+
+```swift
+// AppDelegate.swift
+import UIKit
+import Firebase
+import UserNotifications
+
+@UIApplicationMain
+class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
+
+ var window: UIWindow?
+
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
+ FirebaseApp.configure()
+
+ UNUserNotificationCenter.current().delegate = self
+ Messaging.messaging().delegate = self
+
+ UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
+ print("Permission granted: \(granted)")
+ }
+
+ application.registerForRemoteNotifications()
+
+ Messaging.messaging().token { token, error in
+ if let error = error {
+ print("Error fetching FCM registration token: \(error)")
+ } else if let token = token {
+ print("FCM registration token: \(token)")
+ // TODO: If necessary send token to application server.
+ }
+ }
+
+ return true
+ }
+
+ func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
+ print("Firebase registration token: \(String(describing: fcmToken))")
+ // TODO: If necessary send token to application server.
+ }
+
+ // Handle incoming messages
+ func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
+ print("Message ID: \(userInfo["gcm.message_id"] ?? "")")
+ print(userInfo)
+ completionHandler(UIBackgroundFetchResult.newData)
+ }
+}
+```
+
+## Step 3: Configure Your Firebase Console
+
+Make sure your Firebase project is correctly set up in the Firebase Console to handle Cloud Messaging.
+
+## Step 4: Deploy and Test
+
+Deploy your iOS app and test sending notifications from the Firebase Console to ensure that both foreground and background messages are received correctly.
diff --git a/pages/tutorials/node/Cloud_Messaging.md b/pages/tutorials/node/Cloud_Messaging.md
new file mode 100644
index 0000000..1c1baf5
--- /dev/null
+++ b/pages/tutorials/node/Cloud_Messaging.md
@@ -0,0 +1,69 @@
+
+# Firebase Cloud Messaging with Node.js
+
+## Step 1: Install Firebase Admin SDK
+
+First, install the Firebase Admin SDK using npm:
+
+```bash
+npm install firebase-admin
+```
+
+## Step 2: Initialize Firebase Admin SDK
+
+Initialize Firebase Admin SDK in your Node.js project. This is usually done in a separate file, like `firebaseAdmin.js`.
+
+```javascript
+// firebaseAdmin.js
+const admin = require('firebase-admin');
+const serviceAccount = require('path/to/serviceAccountKey.json');
+
+admin.initializeApp({
+ credential: admin.credential.cert(serviceAccount)
+});
+
+const messaging = admin.messaging();
+
+module.exports = messaging;
+```
+
+## Step 3: Send a Notification
+
+Create a script to send a notification using the Firebase Admin SDK.
+
+```javascript
+// sendNotification.js
+const messaging = require('./firebaseAdmin');
+
+const message = {
+ notification: {
+ title: 'Hello World',
+ body: 'This is a Firebase Cloud Messaging notification'
+ },
+ token: 'RECIPIENT_DEVICE_FCM_TOKEN'
+};
+
+messaging.send(message)
+ .then(response => {
+ console.log('Successfully sent message:', response);
+ })
+ .catch(error => {
+ console.error('Error sending message:', error);
+ });
+```
+
+## Step 4: Run the Script
+
+Run the script to send the notification:
+
+```bash
+node sendNotification.js
+```
+
+## Step 5: Configure Your Firebase Console
+
+Make sure your Firebase project is correctly set up in the Firebase Console to handle Cloud Messaging.
+
+## Step 6: Deploy and Test
+
+Deploy your Node.js project and test sending notifications from the Firebase Console to ensure that messages are received correctly.
diff --git a/pages/tutorials/python/Cloud_Messaging.md b/pages/tutorials/python/Cloud_Messaging.md
new file mode 100644
index 0000000..215207a
--- /dev/null
+++ b/pages/tutorials/python/Cloud_Messaging.md
@@ -0,0 +1,62 @@
+
+# Firebase Cloud Messaging with Python
+
+## Step 1: Install Firebase Admin SDK
+
+First, install the Firebase Admin SDK using pip:
+
+```bash
+pip install firebase-admin
+```
+
+## Step 2: Initialize Firebase Admin SDK
+
+Initialize Firebase Admin SDK in your Python project. This is usually done in a separate file, like `firebase_admin.py`.
+
+```python
+# firebase_admin.py
+import firebase_admin
+from firebase_admin import credentials, messaging
+
+cred = credentials.Certificate('path/to/serviceAccountKey.json')
+firebase_admin.initialize_app(cred)
+```
+
+## Step 3: Send a Notification
+
+Create a script to send a notification using the Firebase Admin SDK.
+
+```python
+# send_notification.py
+from firebase_admin import messaging
+from firebase_admin import initialize_app
+
+initialize_app()
+
+message = messaging.Message(
+ notification=messaging.Notification(
+ title='Hello World',
+ body='This is a Firebase Cloud Messaging notification',
+ ),
+ token='RECIPIENT_DEVICE_FCM_TOKEN',
+)
+
+response = messaging.send(message)
+print('Successfully sent message:', response)
+```
+
+## Step 4: Run the Script
+
+Run the script to send the notification:
+
+```bash
+python send_notification.py
+```
+
+## Step 5: Configure Your Firebase Console
+
+Make sure your Firebase project is correctly set up in the Firebase Console to handle Cloud Messaging.
+
+## Step 6: Deploy and Test
+
+Deploy your Python project and test sending notifications from the Firebase Console to ensure that messages are received correctly.
diff --git a/pages/tutorials/react-native/Cloud_Messaging.md b/pages/tutorials/react-native/Cloud_Messaging.md
new file mode 100644
index 0000000..03ffa76
--- /dev/null
+++ b/pages/tutorials/react-native/Cloud_Messaging.md
@@ -0,0 +1,46 @@
+
+# Firebase Cloud Messaging with React Native
+
+## Step 1: Install Firebase and React Native Firebase
+
+First, install the necessary dependencies:
+
+```bash
+npm install @react-native-firebase/app @react-native-firebase/messaging
+```
+
+## Step 2: Initialize Firebase in Your App
+
+Initialize Firebase in your React Native app. This is usually done in a separate file, like `firebase.js`.
+
+```javascript
+// firebase.js
+import messaging from '@react-native-firebase/messaging';
+
+// Request user permission for notifications
+messaging().requestPermission()
+ .then(() => {
+ console.log('Notification permission granted.');
+ return messaging().getToken();
+ })
+ .then(token => {
+ console.log('FCM Token:', token);
+ // Send the token to your server or use it to send notifications
+ })
+ .catch(error => {
+ console.error('Unable to get permission to notify.', error);
+ });
+
+// Handle incoming messages
+messaging().onMessage(async remoteMessage => {
+ console.log('A new FCM message arrived!', remoteMessage);
+});
+```
+
+## Step 3: Configure Your Firebase Console
+
+Make sure your Firebase project is correctly set up in the Firebase Console to handle Cloud Messaging.
+
+## Step 4: Deploy and Test
+
+Deploy your React Native app and test sending notifications from the Firebase Console to ensure that both foreground and background messages are received correctly.
diff --git a/pages/tutorials/react/Cloud_Messaging.md b/pages/tutorials/react/Cloud_Messaging.md
new file mode 100644
index 0000000..78f33fe
--- /dev/null
+++ b/pages/tutorials/react/Cloud_Messaging.md
@@ -0,0 +1,115 @@
+
+# Firebase Cloud Messaging with React
+
+## Step 1: Install Firebase in Your React App
+
+First, make sure you have Firebase installed in your React project. If not, you can install it using npm:
+
+```bash
+npm install firebase
+```
+
+## Step 2: Initialize Firebase in Your App
+
+Initialize Firebase in your React app with your Firebase project configuration. This is usually done in a separate file, like `firebase.js`.
+
+```javascript
+// firebase.js
+import firebase from 'firebase/app';
+import 'firebase/messaging';
+
+const firebaseConfig = {
+ apiKey: "YOUR_API_KEY",
+ authDomain: "YOUR_AUTH_DOMAIN",
+ projectId: "YOUR_PROJECT_ID",
+ storageBucket: "YOUR_STORAGE_BUCKET",
+ messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
+ appId: "YOUR_APP_ID",
+};
+
+firebase.initializeApp(firebaseConfig);
+
+const messaging = firebase.messaging();
+
+export { messaging };
+```
+
+## Step 3: Setup Service Worker for Firebase Messaging
+
+Create a `firebase-messaging-sw.js` file in the public directory of your React project. This service worker will handle background messages.
+
+```javascript
+// public/firebase-messaging-sw.js
+importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js');
+importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-messaging.js');
+
+firebase.initializeApp({
+ apiKey: "YOUR_API_KEY",
+ authDomain: "YOUR_AUTH_DOMAIN",
+ projectId: "YOUR_PROJECT_ID",
+ storageBucket: "YOUR_STORAGE_BUCKET",
+ messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
+ appId: "YOUR_APP_ID",
+});
+
+const messaging = firebase.messaging();
+
+messaging.onBackgroundMessage((payload) => {
+ console.log('[firebase-messaging-sw.js] Received background message ', payload);
+ const notificationTitle = payload.notification.title;
+ const notificationOptions = {
+ body: payload.notification.body,
+ icon: payload.notification.image
+ };
+
+ self.registration.showNotification(notificationTitle, notificationOptions);
+});
+```
+
+## Step 4: Request Permission to Show Notifications
+
+In your main React component, request permission from the user to show notifications.
+
+```javascript
+// App.js
+import React, { useEffect } from 'react';
+import { messaging } from './firebase';
+
+function App() {
+ useEffect(() => {
+ messaging.requestPermission()
+ .then(() => {
+ console.log('Notification permission granted.');
+ return messaging.getToken();
+ })
+ .then((token) => {
+ console.log('FCM Token:', token);
+ // Send the token to your server or use it to send notifications
+ })
+ .catch((err) => {
+ console.error('Unable to get permission to notify.', err);
+ });
+
+ messaging.onMessage((payload) => {
+ console.log('Message received. ', payload);
+ // Handle foreground messages here
+ });
+ }, []);
+
+ return (
+
+
Firebase Cloud Messaging with React
+
+ );
+}
+
+export default App;
+```
+
+## Step 5: Configure Your Firebase Console
+
+Make sure your Firebase project is correctly set up in the Firebase Console to handle Cloud Messaging.
+
+## Step 6: Deploy and Test
+
+Deploy your React app and test sending notifications from the Firebase Console to ensure that both foreground and background messages are received correctly.
diff --git a/pages/tutorials/vue/Cloud_Messaging.md b/pages/tutorials/vue/Cloud_Messaging.md
new file mode 100644
index 0000000..718d6f2
--- /dev/null
+++ b/pages/tutorials/vue/Cloud_Messaging.md
@@ -0,0 +1,111 @@
+
+# Firebase Cloud Messaging with Vue
+
+## Step 1: Install Firebase in Your Vue App
+
+First, make sure you have Firebase installed in your Vue project. If not, you can install it using npm:
+
+```bash
+npm install firebase
+```
+
+## Step 2: Initialize Firebase in Your App
+
+Initialize Firebase in your Vue app with your Firebase project configuration. This is usually done in a separate file, like `firebase.js`.
+
+```javascript
+// firebase.js
+import firebase from 'firebase/app';
+import 'firebase/messaging';
+
+const firebaseConfig = {
+ apiKey: "YOUR_API_KEY",
+ authDomain: "YOUR_AUTH_DOMAIN",
+ projectId: "YOUR_PROJECT_ID",
+ storageBucket: "YOUR_STORAGE_BUCKET",
+ messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
+ appId: "YOUR_APP_ID",
+};
+
+firebase.initializeApp(firebaseConfig);
+
+const messaging = firebase.messaging();
+
+export { messaging };
+```
+
+## Step 3: Setup Service Worker for Firebase Messaging
+
+Create a `firebase-messaging-sw.js` file in the public directory of your Vue project. This service worker will handle background messages.
+
+```javascript
+// public/firebase-messaging-sw.js
+importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js');
+importScripts('https://www.gstatic.com/firebasejs/8.10.1/firebase-messaging.js');
+
+firebase.initializeApp({
+ apiKey: "YOUR_API_KEY",
+ authDomain: "YOUR_AUTH_DOMAIN",
+ projectId: "YOUR_PROJECT_ID",
+ storageBucket: "YOUR_STORAGE_BUCKET",
+ messagingSenderId: "YOUR_MESSAGING_SENDER_ID",
+ appId: "YOUR_APP_ID",
+});
+
+const messaging = firebase.messaging();
+
+messaging.onBackgroundMessage((payload) => {
+ console.log('[firebase-messaging-sw.js] Received background message ', payload);
+ const notificationTitle = payload.notification.title;
+ const notificationOptions = {
+ body: payload.notification.body,
+ icon: payload.notification.image
+ };
+
+ self.registration.showNotification(notificationTitle, notificationOptions);
+});
+```
+
+## Step 4: Request Permission to Show Notifications
+
+In your main Vue component, request permission from the user to show notifications.
+
+```javascript
+// main.js
+import Vue from 'vue';
+import App from './App.vue';
+import { messaging } from './firebase';
+
+Vue.config.productionTip = false;
+
+new Vue({
+ render: h => h(App),
+ created() {
+ messaging.requestPermission()
+ .then(() => {
+ console.log('Notification permission granted.');
+ return messaging.getToken();
+ })
+ .then((token) => {
+ console.log('FCM Token:', token);
+ // Send the token to your server or use it to send notifications
+ })
+ .catch((err) => {
+ console.error('Unable to get permission to notify.', err);
+ });
+
+ messaging.onMessage((payload) => {
+ console.log('Message received. ', payload);
+ // Handle foreground messages here
+ });
+ }
+}).$mount('#app');
+```
+
+## Step 5: Configure Your Firebase Console
+
+Make sure your Firebase project is correctly set up in the Firebase Console to handle Cloud Messaging.
+
+## Step 6: Deploy and Test
+
+Deploy your Vue app and test sending notifications from the Firebase Console to ensure that both foreground and background messages are received correctly.