我正在调查firebase和angularfire是否适合我即将开展的项目.
其中一个要求是当应用程序在发送给用户的新私人消息上关闭时通知用户,即.推送通知.
firebase会处理这个吗?
我需要在将某个孩子添加到Firebase路径时向用户发送iOS推送通知.
我在想,最好的方法是在Heroku上创建一个Node.js工作人员,它会监听变化并使用Urban Airship发送通知.
我不确定从Heroku上的Node.js工作者那里听Firebase更改的最佳方法是什么.我不熟悉heroku worker和Node.js.
谁能给我一些指示?例子?
我的childAdded应用中的通知表有一个Firebase 事件监听器,我想在应用程序在后台时触发推送通知.
这是听众:
@objc func observeNotificationsChildAddedBackground() {
self.notificationsBackgroundHandler = FIREBASE_REF!.child("notifications/\(Defaults.userUID!)")
self.notificationsBackgroundHandler!.queryOrdered(byChild: "date").queryLimited(toLast: 99).observe(.childAdded, with: { snapshot in
let newNotificationJSON = snapshot.value as? [String : Any]
if let newNotificationJSON = newNotificationJSON {
let status = newNotificationJSON["status"]
if let status = status as? Int {
if status == 1 {
self.sendPushNotification()
}
}
}
})
}
func sendPushNotification() {
let content = UNMutableNotificationContent()
content.title = "Here is a new notification"
content.subtitle = "new notification push"
content.body = "Someone did something …Run Code Online (Sandbox Code Playgroud) ios firebase swift firebase-cloud-messaging unnotificationrequest
我正在尝试使用javascript制作一个"FourConnect"游戏.我想,所有在线用户都有一个列表.这个列表是我在firebase网站上的例子.现在我希望我可以选择一个在线用户并向他们发送邀请来与我一起玩.所以我写了一个函数,所有用户都希望我有一个额外的div.当我点击div时,这个特殊用户应该得到一个确认框来说出okey或取消.如果用户点击该键,则该游戏应该开始.我将保存用户的名称和ID.这已经有效了.
我的问题是,我不知道如何将请求发送给其他用户.我尝试了很多,但总是确认框在我的brwoser上而不是在其他用户的浏览器上.
我在firebase页面和谷歌上寻找解决方案,但找不到任何解决我问题的方法.
我已有的代码:
var name = prompt("Your name?", "Guest"),
currentStatus = "? online";
// Get a reference to the presence data in Firebase.
var userListRef = new Firebase(connectFour.CONFIG.firebaseUrl);
// Generate a reference to a new location for my user with push.
var myUserRef = userListRef.push();
var gameId = myUserRef.name();
document.getElementById('labelGameId').innerHTML = gameId;
beginGame({id: gameId, name: name, status: currentStatus});
// Get a reference to my own presence status.
var connectedRef = new Firebase('http://presence.firebaseio-demo.com/.info/connected');
connectedRef.on("value", function(isOnline) {
if (isOnline.val()) {
// …Run Code Online (Sandbox Code Playgroud)