FCM / APNs =>When specifying apns-collapse-id, old notifications on IOS devices are replaced by new one but new banner is always appearing - push-notification

(notification banner)
What is apns-collapse-id?
https://stackoverflow.com/questions/40009738/ios-thread-id-doesnt-group-push-notifications#:~:text=What%20is%20apns,it%27s%20for%20coalescing!
I am sending notifications to my Ios users(to ios devices) every x seconds.
In this notifications I am informing users about current state of charging of their electric vehicles.
Some of our users are complaining that notifications are annoying and they are popping up too often.
My goal is to replace old notification with new on without interrupting the user. (just replace the data, no sound, no new banner).
On the server I specified apns-collapse-id in notification header. The new notification is replacing the old one but banner is appearing with every new notification and the user is annoyed.
Is this normal behaviour?
Is it possible to disable "banner displaying"?
(Ideal behaviour would be to show banner just for the first notification).
On the server I am using FCM. The type of notification is Notification messages.
Is it possible that this behaviour is bug in FCM?
message.Apns = new ApnsConfig
{
Aps = new Aps(),
Headers = new ReadOnlyDictionary<string, string>(new Dictionary<string, string>
{
{"apns-collapse-id", notification.ThreadId}
})
};

Related

Clearing badges count on RN app using firebase

I have no worries sending push notifications to my RN app from my backend and adjusting badges count there, no matter there are 100 badges or 0. What I am curious about is how to clear that badge count without actually showing any new push notification? Is there any kind of "silent" push notifications that will never be showed but the badge count will be updated? I have this situation since I have web and mobile apps and if the user reads his notifications on WEB I want to reset its count on mobile as well without waiting to open the mobile app.
On my backend I'm using firebase-admin library
yes, it is possible to send a silent push without any sound and appear in notifications with this payload and it will set your badge no. reset means zero and 0 badge will not show
{
"aps" : {
"alert" : "You received simple notification!",
"badge" : 0,
"content-available" : 1
}
}
OR
try options
const options = { content_available: true }
and pass options as an additional parameter
admin.messaging().sendToDevice(tokens, payload, options);

Meteor raix:push: Only "Badges" instead of "Badges, Sounds, Banners" in Notifications settings

In the Notifications section in the Settings app, my app only has "Badges" listed under it where it should have "Badges, Sounds, Banners".
Due to this I don't get "notified" when a new notification comes in, i.e. no banner, no sound, no vibrations. The notification shows up in the notifications tray and on the lock screen and the badge number updates, but there are no alerts.
Any ideas how to fix this?
My config.push.json looks like this:
{
"apn": {

"passphrase": "passphrase",
"key": "PushChatKey.pem",
"cert": "PushChatCert.pem"
},
"production":false,

"badge": true,
"sound": true,
"alert": true,
"vibrate": true
}
And I send notifications like this:
`Push.send({
from: 'Test',
title: 'Hello',text: 'World',
badge: 4,
query: {},
sound: 'default'
});`
(Similar to iOS push notifications only showing badges. need sounds and banners too but using different framework.)
I was able to solve this using the Push.Configure({}) setup on both server and client.
Server code:
Push.Configure({
apn:{
passphrase:'password',
certData: Assets.getText('enter certificate pem file name'),
keyData: Assets.getText('enter key pem file name')
},
production: false //or true if production
});
Client code (including the alert:true is what did the trick for me):
Push.Configure({
badge:true,
sound:true,
alert:true
});

Is it possible navigate to a certain screen after open a push notification toast on windows phone app?

I´m doing an app with push notifications on MFP 7 and I want to open certain screen with specific information after tap on the toast push notification, I have found some information but I don´t know how to pass the parameters of screen and others that i need. I´m using an http adapter to send the notifications
If you're using Event source notifications then you could send a specialized parameter as the payload and check for its value as the app is loading (or when the push is displayed, doesn't matter). Then, change to a specific page content based on the payload value.
For example, here I'm sending the payload as "foo" with value "bar":
WL.Server.notifyAllDevices(userSubscription, {
badge: 1,
sound: "sound.mp3",
activateButtonLabel: "ClickMe",
alert: notificationText,
payload: {
foo : 'bar'
    }
});
And in the app logic I check for the value:
function pushNotificationReceived(props, payload) {    
if (payload.foo == "bar") {
// change page, etc and display the message
    }  
}
You can also use Tag-based notifications (in case the information sent via push notifications is not sensitive information) and then act based on the tag. You can read more about tag notifications in the Developer Center: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/notifications/
Assuming MPNS notifications and query is about Windows Phone silverlight (hybrid), to navigate to specific page when a toast notification arrives, first you will need to specify the page and other details in "param" of MPNS toast.
http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.apiref.doc/html/refjavascript-server/html/WL.Server.html%23notifyAllDevices
Refer specifically to the notification options under MPNS -> Toast
Eg:
var notification = WL.Server.createDefaultNotification(notificationText, badgeDigit,{custom : 'data'});
notification.MPNS.toast={text1 : "hello" , text2 :"world",param:"/MainPage.xaml?value1=54321"};
WL.Server.notifyAllDevices(userSubscription, notification);
To retrieve the value received (in this example, 54321) , to the best of my understanding there is no straight way. You can write a Cordova plugin
that can retrieve the value and use it to obtain the value assigned to the key "value1" in the example.

Parse, how to send push notification to targeted users

I have successfully setup parse push notifications and in my installation table I have both an installation, and device token. What I'm really trying to do is send a push notification to certain users, rather than certain devices. How do I bing the installations table to the uses table, so that I can make a query by users and get back a deviceid to push to
From https://parse.com/docs/push_guide#top/iOS, section "Using Advanced Targeting".
You can even create relationships between your Installation objects
and other classes saved on Parse. To associate a PFInstallation with a
particular user, for example, you can simply store the current user on
the PFInstallation.
// Associate the device with a user
PFInstallation *installation = [PFInstallation currentInstallation];
installation[#"user"] = [PFUser currentUser];
[installation saveInBackground];
Now you can create a query on the installation table, where "user" is the user you want to send a push notification to.
Finally, use that query when constructing the push object.
Example in Objective-C (adjust accordingly, if you're sending the push in some other language):
PFQuery *pushQuery = [PFInstallation query];
[pushQuery whereKey:#"user" equalTo:someUser]; // where some user is the user object that is to receive a push notification
PFPush *push = [[PFPush alloc] init];
[push setQuery:pushQuery];
[push setMessage:#"Hi there!"];
[push sendPushInBackground];

Push sharp: Sending same message again and again

I am new to Push Sharp.
I am trying to send messages to Android devices using Push Sharp. It works great but the problem is that Push Sharp is sending same message again and again.
My Code is:
AndroidPushBroker = new PushBroker();
var googleKey = CustomConfigurationManager.GetValueFromSection("appSettings", "GoogleServerAccessKey");
AndroidPushBroker.RegisterGcmService(new PushSharp.Android.GcmPushChannelSettings(googleKey));
var jsonMessage = "{\"InformationId\":\"" + notification.Message + "\",\"badge\":7,\"sound\":\"sound.caf\",\"NotificationType\":\"" + notification.Type.ToString() + "\"}";
GcmNotification androidNotifcation = new GcmNotification().ForDeviceRegistrationId(notification.DeviceId)
.WithJson(jsonMessage);
AndroidPushBroker.QueueNotification(androidNotifcation);
Issue: When i send message "Message 1" and then later on send "Message 2", it sends "Message 1" again. Do I need to remove items from Queue ? Or what am I missing. ?
Note: I have single instance of Push Broker in my application.
I'm not very experienced with PushSharp either, but my guess is that you are not emptying the notification queue after sending your message.
Try to add the following after your QueueNotification call
AndroidPushBroker.StopAllServices();
Finally I got the issue.
I was registering my gcm service again and again which was causing duplicate events.
AndroidPushBroker.RegisterGcmService(new PushSharp.Android.GcmPushChannelSettings(googleKey));
This should be called only once.

Resources