Out of nowhere my bot stopped receiving post-backs from Messenger.
Yes, I have messaging_postbacks ticked in the event list. The bot receives text messages just fine.
Heroku logs show that when I press a button in the chat, the webhook is not called at all, so it's not a bug in the code. Was there some kind of recent change to the post-backs perhaps?
Related
I am building a chat feature using firebase Realtime database where an integer variable stores a number (int online) which when a chat is opened by person A it adds 1 to the database and then if another person B comes online and opens the chat then it adds another 1. So, if the number is 2 I know that both are online and active in the chat app so no need to send push notification.
But the issue that I am facing now is that if a user closes the app without pressing the in-built back button of the chat app (which when pressed subtracts 1 and becomes 0 when both users are inactive), then the number in the database is not changed which causes error in the push notification logic as when Person A sends a message, the code assumes Person B is online. How could this be solved? Please someone help me understand how push notifications generally work?
First off all sending push notifications is completely FREE. The only costs are made by the the backend (cloud functions) that executes the code to send them.
Secondly. If your users are in the app no push notifications will be shown. Even if you would like to show some in your app you would need to handle the onMessageReceived to show something to the user while he is in the app.
That means there is no need for you to do the thing you try to do. Just send all messages as if no user is in the app. It would even cost you more to check for each user if he is online or not and send the messages only if he is offline than just to send them to everyone.
I would recommend to read the docs a little bit to get a deeper understanding of FCM and if you have any specific questions we can all help you with it :)
I had a flutter app with a chat room feature. Firebase messaging is used to push remote notification. I want to hide the notification popup if the app is at foreground and it happens to be at the exact chat room where that coming notification belongs to.
This is a common behavior when you're chatting with someone. The message appends to chat room directly instead of popup.
My question is how to interfere the remote notification on receiving? I used onMessage callback on notification received event. But it always popups no matter the app is at foreground or background or termiated.
In firebase React Native version, it has an onNotification callback which does exactly what I want. But there is no equivalence for flutter. My research leads me to send Data and Notification type of message. In such a way, I need to keep app status synchronized with my backend server (Am I right?).
Any help or suggestion is welcome. Thank you.
P.S. firebase_messaging 8.0.0-dev.10
Update:
As mentioned by op, the problem was fixed when using to the latest stable version (7.0.3). Then the cause is a bug in the new dev release.
Related GitHub issue, Link
Original Answer:
Judging by the issues that you described, the problem that you are running into might be because you are on the dev channel.
Did you try to use the latest stable? (7.0.3 at the time of writing). It might be a bug in the dev channel.
If the problem persists, try sending a data message instead of the notification message. This will stop firebase from sending a notification on the device. But be aware that you will have to display a notification manually. This way you will have control over the display of the notifications based on the screen and wouldn't have to keep the state in sync with the server as you were mentioning.
But this might not work on iOS since according to the docs, onMessage() will be triggered when the app becomes in foreground.
Check the link above for more details on how the notification message and the data message gets handled on both Android and iOS.
If your onMessage does not have code to handle the notifications, then they shouldn't appear.
If You want to convert your onMessage notification, in a overlay or In App Notification then it would be better.
I was also facing the same Issue for showing the notification, and found a workaround for that, We can show the In App Notifications in our App
Instead of showing the notification code in your onMessage method, you can show a overlay, like instagram shows on the top when a notification arrives,
And to append the message to direct chat room, I used some backend help.
onMessage: (Map<String, dynamic> message) async {
showOverlayNote(message);
},
And now you can show the overlay as
showOverlayNote(message){
//your code here for showing the overlay
}
You Can get a Detail on how to use overlay for In App Notificaions from this link
This guy have explained the use of this In App Notifications better, So Please see the above link.
You're thinking about it from the wrong angle. Firebase messaging is always going to trigger your onMessage, it's up to you how you handle that internally.
I'd suggest using a state manager - Mobx, ChangeNotifier, a file, whatever - to keep track of what screen the user is on. When the user enters your chat screen, write that to your state manager (also "un-write" that upon your dispose() method if necessary).
Then, in the method that handles onMessage, check for the user's current screen. If they're on the chat screen then exit, if not, execute the overlay.
I'm trying to make an App that's exactly like WhatsApp, so far the biggest limitation is that when a user re-opens the App after a while, and goes to a Conversation View, new Messages that were sent during the time the App was in Background/Suspended or Terminated states have to be recovered from a Server (API), and this causes a potential delay for new messages showing up in the Conversation View.
How can I achieve permanent Sync of an App with a server API? I'm kind of sure apps like WhatsApp manage to do this, because Messages never appear to be downloaded whenever you re-open the App after a while, right?
What is the right way to sort of Mimic this type of behavior? I really want to learn how to perform this kind of "advanced" synching and I don't know where to get started. Again, my goal is to try to avoid server-downloads of new Messages when a user re-enters a Conversation Viewfor example (because that would be bad UX)
Thanks in advance!
Your app will need push notifications. This is a must have for apps like this.
On the server, when you know that there are new messages, send a push notification to the app. This will let the app know that there are messages to read. At this point the app can badge the app icon, pop an alert and show on the notification screen. The user controls how notifications appear.
Details about notifications here:
https://developer.apple.com/notifications/
Your app can load all messages when it gets the notification.
iOS apps do have some limited options for background processes: https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
My bot sends 2-3 messages at a time as apart of the conversation. This can get annoying when Slack beeps for every message. Is there a way to silence this. Facebook allows me to set a message type to silent to prevent beeps
No, there is not "silence flag" for messages in Slack. Here are your other options to prevent "beeps":
Mute channel
You can mute a channel so you wont get any notification for it. See this link for our to mute channel in your Slack client.
Notification settings
You can turn-off the "beeps" for every new message, but still get visual notifications about new messages. See this link for how to change notification settings.
How can I send a text message (natively or through the use of an API) from an iOS application to someone without having them have to interact with the message before hand?
The message would be prewritten and would send on tap of screen. Its ok if the user needs to okay it once, but I need a way to send a message without having to have the user interact with their device each time.
Example:
Phone is off, I shake phone, phone senses shake, sends text messaging saying "I'm shaking" to another user via SMS or MMS without having the user need to OK the sending. Is this possible? How would I do it?
You can't do that. You need to show the user the message in the MFMessageComposeViewController that pops up first, and he has to send it by himself.
This restriction was made, because otherwise, many apps could spam your contacts etc. with a massive amount of sms or they could even write sms to expensive numbers.
But if you want to send just some kind of notification to another user, you could use push notifications. To do that, I would recommend you to use parse.com and their free push notification-service. Also, because Push Notifications are free, in contrast to SMS, you will save a lot of money. Of course you need to make some preparations before you can send notifications, but that way you could do it. But also there are restrictions. One restriction is, that the receiver of the notification also must have the app installed on the receiving device.
So the receiver would receive a "message" like that:
So I would recommend you to check the QuickStart Guide from Parse.com for iOS for further informations. The Guide is really simple and shows you step by step how to activate your app for Push notifications.
Sorry, but you can't, it is completely impossible. The only way to send sms is through messageUI, which always requires the users consent. You can probably do it on a jailbroken phone, though.
Yes, it is possible. But you would have to use a 3rd party service to send the text message. for example, Twilio.