FirebaseMessaging on iOS - how to get topic through which a message was sent? - firebase-cloud-messaging

I'm using FirebaseMessaging with topic subscription on iOS.
I'm receiving messages in the application(_ application:, didReceiveRemoteNotification userInfo:, fetchCompletionHandler completionHandler:) method as expected, but I can't find a way to get the topic name through which a given message was sent.
Is it possible? I can't find anything like that in the userInfo value that I get in that method.
On Android it's easy: RemoteMessage.getFrom() returns exactly what I need.

No information about the topic is included in the data that Firebase Cloud Messaging delivers to your iOS application code. If you want to know the topic, you'll have to include that in the payload that you send.

Related

Can't receive WhatsApp message notifications via webhook

I set up a glitch service as described in the Meta doc to receive notifications of WhatsApp received messages via a webhook. However, messages notifications are not received at all, not even pressing the test button of the webhook. Please, note that it's not a general configuration problem, since other notifications (e.g., account_alerts) are properly received.
(I'm using the test phone number provided by Meta)
Any hints about this issue?
Turned out it was a bug: https://developers.facebook.com/support/bugs/856675538926230/
(Now it seems fixed)

Is it possible to read bot Telegram messages

I have successfully created a bot with and am able to fetch messages from a chat using the getupdates method (long polling).
The getUpdates method is only showing user posted messages (clientside). When I post messages directly using the sendmessage method (serverside) these messages do appear in the chat, but do not in the getUpdates log.
This page https://github.com/LibreLabUCM/teleg-api-bot/wiki/Getting-started-with-the-Telegram-Bot-API#getupdates
states it logs only when "An user messages your bot, either directly or in a group." and some other ways, but the sendMessage way is not mentioned.
I've read a bit on the setwebhook method (push) but am not sure this will fix my issue.
Is this possible?
According to Bot FAQ, bots will not be able to see messages from other bots regardless of mode.
The getUpdates method shows only updates from users, not from the bot itself. This means that when you fetch the new messages with the getUpdates method, the Telegram API will list only the messages sent by the users, not the messages sent by the bot via any method (e.g sendMessage, sendPhoto ...).
To get old messages you can store the entire update (or only the parts of the update you need) for each message (even those sent by the bot with the sendMessage method) in a file or in a database and when you need an old message you can simply fetch it form the database or the files.
I managed to get the bot messages using two bots.
One does the sendMessage method and the other one does the getUpdates method.
#Giolacca9 answer inspired me to try this workaround and it works, "not from the bot itself" :)

Process SMS when notified via websocket

So I managed to connect to the websocket with my API token and I do get notifications. For incoming calls, I do get a push with all info like so:
{"type":"push","targets":["stream"],"push":{"type":"mirror","source_device_iden":"XXXXXXX","source_user_iden":"ujC7S24sQxw","client_version":206,"dismissible":true,"title":"5555551212","body":"Incoming call","application_name":"Pushbullet","package_name":"com.pushbullet.android","notification_id":"6","icon"
"Big value here"}}
So I can see that call came from 555-1212 (I changed number for privacy) and it all makes sense. However, for SMSs, all I get is a notification that SMS changed. No body field so I can't see where it came from and what the message is. All it says is sms_changed for type:
{"type":"push","targets":["stream"],"push":{"type":"sms_changed","source_device_iden":"XXXXXXXXX"}}
What am I doing wrong? I would like to get the SMS message and sender info so that I can publish it. Any and all help will be greatly appreciated.
This is not publicly documented yet and we might be changing the implementation in the near future so I'm hesitant to make it public. Also I don't know the specifics of the current implementation.
You can view how it works right now by using www.pushbullet.com and looking at the network traffic (in chrome inspector) when you do SMS stuff on the website.

Android phone won't receive SNS push notifications

I have a few Android phones. I'm pushing messages to them via Amazon SNS to GCM, using boto in Python. One phone always receives the messages. The other one does not.
The first time I send a message to the problem phone, it appears to succeed but nothing goes through. When I go to the AWS console and look at the list of endpoints registered to my app, it now shows "false" under the Enabled column.
The second time I send a message, boto raises an exception with a message in it: "Endpoint is Disabled"
What are some reasons why an android phone would not receive GCM messages? Are there user settings that can disable this?
Probably you figured it out, however, I post the answer for future use. This is a good article around this topic and addresses some possibilities about the problem.
Based on your explanation I think the Token for the android phone is expired and it needs to get re-registered with the GCM, then the SNS endpoint should be updated.
Token may have expired, or it may have been cleared from the app's storage. On your Android app, create a class that extends FirebaseInstanceIdService and override this function:
#Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "Refreshed token: " + refreshedToken);
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
sendRegistrationToServer(refreshedToken);
}
Also create your own sendRegistrationToServer. On your backend, implement a function that receives the token and assigns it to that endpoint's ARN. This way, your backend will always know where to send the notification.

C2DM collapse_key implementation explanation needed

hi
I cannot see any explanation of the implementation of the collapse_key.
I think i understand what it does but not how it do it!
Android Cloud to Device Messaging Framework
I have a C2DM framework set up and sending 4 types of messages to many phones.
String messages very basic looks kind of like this:
type:name:uuid
type:name:uuid:number
type:uuid:id
If the phone is off many of this can get piled up waiting for phone on-line.
as far as i can tell my system works but what will the collapse_key do for me here?
addEncodedParameter(sb, "collapse_key", "no_ide_what_to_put_here");
You mentioned retrying the same message 3 times and using the same key value. It doesn't really have to be the same message. If you've got a message that indicates the current price of a stock, for instance, and you really only care about the latest price, then you could send different messages with the same key. When the device comes back online, it only gets the latest price quote message.
This may have been what you were saying already, but wanted to make it clear it's not only for "retrying sending same message".
I found this text: “collapse key” used for overriding old messages with the same key on the Google C2DM servers" I think if im retrying sending same message 3 times I must use same key value right. Google cloud server will send the latest msg with the same key value
...but be aware of the following (from http://code.google.com/intl/sv-SE/android/c2dm/):
"Note that since there is no guarantee of the order in which messages get sent, the "last" message may not actually be the last message sent by the application server."
But maybe this is not an issue if you don't generate a lot of messages.