We are able to send currency via the Custom data parameters in Firebase Cloud messaging (see SS below).
But if the user does not tap the notification "YOU RECEIVED 15 FREE GOLD!" then Firebase.Messaging.FirebaseMessaging.MessageReceived is never fired and the user never gets their currency. So the user may see the notification, and then be disappointed the next time they open the app and there is no gold.
Is there a way in Firebase to compose the notification so that the notification can be accessed even if the user did not tap the notification to open the app?
Without tapping on notification your application not launch and custom data you sent through notification is not received to the application. So sending custom data through firebase push notification is wrong choice in this scenario. You should sent custom data whatever you need through API is always good choice. You can also use firebase database and in that you can send custom data using nodes for respective user.
Related
I am trying to make an app which listens to changes of the Internet API even if the app is closed, and sends push notification to the user who set up some value matching conditions with the value from the API. I am new to push motifications and I am not sure if is that possible with natvie notifications system or I have to use some 3rd parties like Firebase Messaging.
I am creating a framework that can receive custom (a certain data model) messages from firebase. The framework is going to be implemented to receive notifications that are not related with the app but with other stuff.
So the framework is going to handle all the display issue by translating the data received and create a notification as it is indicated (I have some flags in data receive that indicated if I should use an image or attach an icon .. etc).
So I did some research on how to receive messages from FCM.
In first instance, I found direct channel that allows to bypass APNS, the problem is that, this only works with the app in foreground.
I indeed create a test project in firebase, a single view app, register my app in firebase project, set info.plist, configure , and send a notification to my app and It worked (just when the app was open).
Then I looked for another choice, and I found APNS. Skiping all the process for validation between firebase and APNS. I found that when you have all set up (and you put all initialization in didAplicationFinishLaunching) your app is able to receive notifications from firebase (Through APNS) when applicaton is in background.
But, notification received (the one that gets displayed) is just for you to tap over it and then it will fire up the app again an only then you will receive the whole data in aplication:didReceiveRemoteMessage method.
My question is, is there a way I can get this custom messages even in background and when received I can display a notification with the content of the whole message?
Yes,
Fortunately you can do that but for that you need to send Silent Notification which will let you process the notification in background and schedule local notification to trigger it with you desired data.
I am creating an app using Swift and Firebase. When the user presses a button the app will upload some data to the real time database and send another user a Push Notification. Is possible by making the other user subscribe to the changes in the realtime database or will this not check for changes when the app is not in the foreground?
Should I upload the data then use Cloud Messaging to alert the user of the new data?
Thank you
You should use FCM for this use case. Having the app listen for changes to the database while in the background is not good for device battery, so you should have your application server listen to the database for changes then send appropriate FCM messages to let the client app know that there are changes.
I'm implementing an iOS chat app using Parse. Currently, most chat data is stored on the user's device.
When you send a push from one user to another, and the receiving user is on the app, the device will save the message along with its data (who it's from, when sent, etc). From there, if the receiving user is chatting with the sending user, their chat dialog will update. If they are still using the app, but not chatting with that user at the moment, a popup will display with the message.
This works great for when they are in the app.
But when they are outside of the app, a push will come through with the data (message, who sent it, when sent, etc), and a push notification will popup on the user's screen. But when they open up the app, I am not sure how to transfer that data from the push to the app's storage.
I guess I do understand how to do it (if there was only ONE push notification AND the user opened the app by tapping the push notification: there is a delegate method that seems to have a dictionary of the push notification's data).
However, in the case of there being multiple messages being sent before the user opens the app, and/or the user opens the app using the app icon (and not by opening the app from the notification), I am not sure how to access this data. It would seem like there would be some sort of way to get an array of dictionary objects, but I'm not sure.
I know I could implement a way to store the data on Parse, and then delete it when it has been downloaded, but if I don't have to do it that way, I wouldn't want to.
Any help would be much appreciated :)
You'll need to store the data in Parse and allow them to query all messages since they last checked.
I would suggest using a counter every time a message is saved, that way in the receiver you can check if that counter has only gone up by one compared to a local copy of the counter, which means you can just use the message in the push notification. If it has gone up by more than one then you know you have to ask Parse for the rest of the messages.
You can have Cloud Code that each participant in the chat calls to say what number they're up to... then you can delete anything with a value less than the lowest of all the participants. You could even integrate this logic into the getMessagesSince(counterValue) call.
Note that in this case you would also want a gotMessageFromPush(counterValue) to let the server know that you got a message via Push.
I am create a firebase based chat application for iOS. One of the features is to send push notification to the users in the same chat room (if they are offline).
I can't find a firebase function (for iOS) that can be used to send push notifications to the user.
Is it possible?
Displaying alert badges and notifications on iPhone applications is accomplished through Apple's Push Notification system. Since the application is not running on the user's phone when they receive notifications, the APN will have to be triggered from your server-side code.
You'll probably want to create a server-side module that listens for changes to your chat Firebase. When a message appears for a user that is offline, you'll have to schedule a remote notification with the APN. That latter part has nothing to do with Firebase, but has extensive documentation on Apple's developer web site.
I'm not sure if a web application can display alerts or badges. Otherwise this approach will only work if you create a native wrapper for your Firebase chat application.