Android phone won't receive SNS push notifications - google-cloud-messaging

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.

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)

Prevent device notification client side with React Native Firebase when a FCM notification arrives (based on user preferences)

I'd like to know if there any a way to prevent the device display a notification when a FCM message with a notification arrives, in case the user has decided to mute notifications and only have them arrive silently (making them act as data only messages, but being notification messages). I imagine like, in the handler/callback call a method to prevent the device notification and do extra processing afterwards.
I know I can use data only messages, but that approach would be harder since I must use multiple topics or token lists and somewhat more backend logic to achieve that.
Thanks
If the message contains a notification property, it is automatically handled by the OS when the app is not active. There is nothing you can do to prevent that.
As you said: if the message only contains a data property, it is always passed to your code for handling, and you can decide what to do with it. So that's the way to go if you want full client-side control over whether a notification is displayed for a message.

Telegram Bot - Send Info message

currently I am working to creating telegram bot. Now I required to know is there is any API to send info messages (like the one we get during a user is added r deleted in a group chat)
Thanks in advance
What you want to do can be done using answerCallbackQuery method.
But first of all you have to create a CallbackQuery using InlineKeyboardMarkup to create inline keyboards you can follow the steps in this link.
After creating the callback query you have to answer it using one of the codes below:
if (update.CallbackQuery.Data == "CQ1")
{
await Bot.AnswerCallbackQueryAsync(update.CallbackQuery.Id,"Text",true,null, 0);
}
This way the message will look like a message box and will disappear after the user taps on OK. But if you use the code below, the message will show up and disappear automatically after a few seconds.
else if (update.CallbackQuery.Data == "CQ2")
{
await Bot.AnswerCallbackQueryAsync(update.CallbackQuery.Id, "Text", false,null, 30);
}
By the way, messages that are shown at times like adding a user to a
group are service messages and theses kinds of message can only be
sent by telegram server.
If my suggestion does not fix your issue you can use pinMessage method
that sticks a single message to the top of the page in groups and
channels. But note that you can only pin one message to a channel
or group and for pinning another message firstly you should unpin the
previous one.
Currently there is no way to send such info messages.
And in my opinion, this feature is unlikely to be added in future because:
info messages usually tell you information about your chat; they are managed by telegram servers
therefore they should not be sent by Users
bot is an instance of User

Firebase cloud messing : How to differentiate among different topics

There is topic subscription function in firebase cloud messaging.
But, how do I differentiate which messages received through notification belong to which topic?
When I subscribe to a topic for example.
Messaging.messaging().subscribe(toTopic: "news")
And when I send the message, I receive the message from the back end in this format in the app .
the full messag is this = [AnyHashable("google.c.a.e"): 1, AnyHashable("google.c.a.ts"): 1500271703, AnyHashable("google.c.a.udt"): 0, AnyHashable("gcm.n.e"): 1, AnyHashable("aps"): {
alert = "google is hello world";
}, AnyHashable("google.c.a.c_id"): 967226232057261708, AnyHashable("gcm.message_id"): 0:1500271704062691%515abe1d515abe1d]
As we can see that, the message we receive contains no "topic" field. So how do we know whether this message is sent under "news" topic or another topic?
Thanks
Firebase Cloud messaging work as Triggers in database, in our Programming we defined one receiver for receive any trigger call and another is handler for handle that function during receive a Trigger call.Every Trigger defined by a unique identifier for handle all these procedure.
Firebase cloud message help to implement instant chat functionality in a application because these trigger directly connect with firebase database. Whenever we do any thing in database like Addition,Deletion,Insertion and updating then Trigger automatic reflect in a project.
Thanks

Multiple push channels (WNS) for a single app?

Basically I have two distinct services I wish to use (my own WCF back end service) and an Azure Mobile Service that both use push notifications. They're associated with the same app in the windows store.
In my code, I have two separate modules that call.
var newChannel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
This all seemed like fun and games and unless I horribly misread the documentations, having multiple channels for one App should be ok.
However, when I sent a notification from the WCF service to the app, it went to the AMS handler and naturally threw an invalid format exception given that I'm using my own Raw push notification format.
So my question is this; do I need to re-engineer the structure to have only one push channel handler that will divide the messages based on their format to the correct handlers, or what is the methodology I need to follow in order to get multiple push channels for a single app?
See the only formats being supported in wns push notification us either e xml based format or the json data format. If while communicating to the wns you are sending some other format then then it is bound to exceptions. ? Go through the demo from the link
Push notification sample
if this does not solve the problem then please leave a comment behind