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);
Related
(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}
})
};
I am using the In-App Billing Plugin for Xamarin and Windows to implement non-consumable in-app purchases.
I have an issue that the payments are refunded for Android devices because I didn't implement the Acknowledge purchase.
The documentation advises adding the code below, but I still get a refund within three days of an item has been purchased.
if(purchase.State == PurchaseState.Purchased)
{
if (DeviceInfo.Platform == DevicePlatform.Android)
{
await billing.AcknowledgePurchaseAsync(purchase.PurchaseToken);
}
//consume an item
}
You are not storing the result - change it to
BillingResult billingResult = await inAppBilling.BillingClient.AcknowledgePurchaseAsync(acknowledgePurchaseParams);
if (billingResult.ResponseCode == BillingResponseCode.Ok)
{
// whatever you need to do with the result
}
Note my code is not using the plugin. But you need to do the check to see what the billingResult.ResponseCode is to be able to debug it.
If you are doing this within a fragment then you will also need to do the same in your MainActvity's OnResume, as there maybe a delay before you get a BillingResponseCode.Ok. Read the Android docs about the reasons for the delay. https://android-developers.googleblog.com/2020/06/meet-google-play-billing-library.html
Also note that you should verify the PurchaseToken against your backend server before acknowledging the purchase.
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
});
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.
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];