Last active
October 25, 2017 02:28
-
-
Save r3-yamauchi/7984d71bd30c6207eb6a4b848d39a2f6 to your computer and use it in GitHub Desktop.
Cloud Firestore を使って kintone へ プッシュ通知する https://blog.r3it.com/cloud-firestore-with-kintone-aaa50fcea1c7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
"use strict"; | |
firebase.initializeApp({ | |
apiKey: "XXxxXxXXXx99x9XX-xxx_xxXxXXXXXXxXXxXXxX", | |
authDomain: "projectId.firebaseapp.com", | |
projectId: "projectId" | |
}); | |
// Initialize Cloud Firestore through Firebase | |
var db = firebase.firestore(); | |
kintone.events.on("app.record.index.show", function (e) { | |
db.collection("users").doc("user1").collection("documents") | |
.onSnapshot(function (snapshot) { | |
if (snapshot.docChanges.length != snapshot.docs.length) { | |
snapshot.docChanges.forEach(function (item) { | |
var doc = item.doc; | |
var data = doc.data(); | |
console.log(doc.id, " => ", data["content"]); | |
swal({ | |
title: data["content"], | |
text: "", | |
timer: 5000 | |
}).then(function () { }, function (dismiss) { }); | |
}); | |
} | |
}, function (error) { | |
console.dir(error); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment