I'm looking for some guidance.
I'm using Firebase as the backend server for an app I'm building and I would like to alert users when somebody has either liked or disliked some content the user generated.
I understand that Firebase offers cloud messaging through which I can target very specific users and send updates to them; I have implemented that functionality. However, I would like to send updates based on changes in the database, and, as far as I understand, FCM is not built for this purpose.
I have come across OneSignal and it seems promising. Has anybody implemented this with Firebase and could it do what I'm looking for?
Thanks!
I have it set upon such a way that when a message is send by a user to another user, a notification is also send via OneSignal. You just need to store the OneSignal userId in a node with the firebase user UID.
I you like someone's content, then that would also send a notification out directly to the other user.
Related
Im currently developing an app in Swift. I'm at the last stage of the app where I just need to integrate push notifications to the lock screen when certain user actions occur.
I'm going for something like how Instagram sends a push notification when a new user follows you or likes your post.
My entire backend is using firebase, and i've looked into firebase cloud messaging and I dont know if it has the capability to perform notifications like this.
I've watched tutorials and read documentation and I know you can push notifications to users from the console but I'm looking for notifications to be published and pushed based off specific user actions.
I know this is a very broad questions so what I want to know is:
A) Are notifications like instagram possible through Firebase cloud messeging?
B) If not, can you point me in the direction of how to figure this out?
Thank you!
A) Are notifications like instagram possible through Firebase cloud messaging?
Yes
Firebase send the push to APNS first then APNS send push notification to iOS devices.
If user 'A' do any action then that specific action will be transferred/send to staging/production server via apis. Based on your business logic staging/production server will send push notification to users(FCM token).
I hope this is helpful or you can explain the exact issue your are facing.
I am trying to send notifications to users when something happens in their account, for example a new friend request or follower, or a tag in an image. I have been looking into Firebase FCM to make this happen but can't figure out how to send push notifications to just 1 user, based on some activity in their account.
Is there any way this can be done in FCM or are there are any other methods out there to make this happen? I'm new to iOS dev and push notifications, so any help will be greatly appreciated!
Thanks!
PS: If I do need to make my own server for this, could someone point me to any resources to do this in python? I've seen quite a few posts for APNs servers in PHP, but I don't know PHP that well.
The easiest way is to use Firebase Cloud Functions , I have experience working with it using Javascript then trigger the function when something changes in database. You can also send a http request with the specific device token which you want a push notification to be delivered to, then the function will do it's magic for you. Firebase have ready to use samples from their Github repo.
NB: - For your case if you really want to use Python then check this answer it might help you get started.
Is there any way to see number of successfully sent and failed push notifications in Firebase Cloud Messaging (FCM) ? I can see the messages sent using the Firebase console but I need to track the number of messages sent via the web app to the devices.
Google explains how to get access to statistics on android https://support.google.com/googleplay/android-developer/answer/2663268. But is there a similar way for iOS?
In one word yes, You can do it.
Firebase API have a message_id as a response parameter. It's indicate notification is deliver or not.
message_id: String specifying a unique ID for each successfully processed message.
Please find below attached screenshots.
Please do refer this reference.
Update:
You can not track user activity for notification in iOS application. If you want to
implement above functionality then call any custom API and store required data into your
database. You can not get any history directly.
I have a fully functioning application that uses Firebase as a backend. I want to be able to have a user receive a notification when a child is added to my Firebase database under that users ID.
I have looked everywhere but all I can find are links to OneSignal or people telling me to "make a custom server" as if it can be done by magic. How do I go about making a server? What language? What do I do with OneSignal? Can someone guide me step by step without telling me to simple make a custom server.
I believe Cloud Functions for Firebase is exactly what you're looking for. Specifically, Realtime Database Triggers:
The Realtime Database supports the onWrite() event, which triggers anytime data is created, destroyed, or changed in a specified database location.
In a typical lifecycle, a Firebase Realtime Database function does the following:
Waits for changes to a particular database location for write events.
Fires when a write event occurs and performs its tasks (see What can I do with Cloud Functions? for examples of use cases).
Receives an event data object that contains two snapshots of the data stored at the specified path: one with the original data prior to the change, and one with the new data.
And going through the What can I do with Cloud Functions?, theres Notifying users:
Notify users when something interesting happens
Developers can use Cloud Functions to keep users engaged and up to date with relevant information about an app. Consider, for example, an app that allows users to follow one another's activities in the app. In such an app, a function triggered by Realtime Database writes to store new followers could create Firebase Cloud Messaging (FCM) notifications to let the appropriate users know that they have gained new followers.
The function triggers on writes to the Realtime Database path where followers are stored.
The function composes a message to send via FCM.
FCM sends the notification message to the user's device.
To review working code, see Send FCM notifications.
Other interesting notification use cases
Send confirmation emails to users subscribing/unsubscribing to a newsletter.
Send a welcome email when a user completes signup.
Send an SMS confirmation when a user creates a new account.
We are developing an iOS application which has a chat through JSQMessagesViewController and Firebase. When a message is sent by one user, the other user will receive a notification for the message. However, we desire a functionality where if the other user is in the chat, he should not receive the notification as he can already see all the chat-messages.
What is the best logic / way to implement this desired functionality?
Xcode 8.1, Swift 3, Firebase, JSQMessagesViewController
According to me there are two things that you can do:
1)You can use observers, like typing , for mapping two users when they are in private chat. Just make a status key on firebase and set it to true if two users are on chat page. In this case just don't send push as probably you are sending it from client end.
2)Or you can just ignore notifications when application is active when you see that payload has same user with which you are chatting.
You would probably need to add a presence management system. I did something similar on my app while using Firebase and JSQMessagesViewController, you could probably customize the system to your liking.
Depending on what you use database wise for incoming and outgoing messages with the JSQMessagesViewController library, you could probably set it up there as well.
Firebase has worked best for me for what you're looking to do:
https://firebase.google.com/docs/database/ios/offline-capabilities