Closed Niko-by closed 1 year ago
If your app is closed with terminated (forced to stop) status, on any platform, any push until the app is reopened by the user will be denied. The concept of forced to stop may change between Android distributions.
Also, you shouldn't use awesome_notifications
and firebase_messaging
together. Take a look at:
https://github.com/rafaelsetragni/awesome_notifications#%EF%B8%8F-attention-%EF%B8%8F--users-from-firebase_messaging-plugin
If your app is closed with terminated (forced to stop) status, on any platform, any push until the app is reopened by the user will be denied. The concept of forced to stop may change between Android distributions.
Maybe I explained badly
How to reproduce the error:
Try to get your device log using "Console.app" on macOS and you can find out why your notification is not being delivered.
OBS: awesome_notifications_fcm also uses Firebase services. Are you using awesome_notifications_fcm in your project?
On first submit in macos console I see this error:
AMSURLSession: [AEE04261] Task completed with error = Error Domain=AMSErrorDomain Code=301 "Invalid Status Code" UserInfo={NSLocalizedFailureReason=The response has an invalid status code, AMSURL=https://sandbox.itunes.apple.com/commerce /messages/app/inbox?bundleId=com.realconstruction.ios&guid=...........&status=1, AMSStatusCode=412, NSLocalizedDescription=Invalid Status Code}
When resending, there is no error, the notification was delivered (at the same time, the application did not start, it was still closed, I think this is not related to closing the application).
But I have an old code implementation, I still use awesome with firebase_messaging.
I will try to transfer the project to awesome_notifications_fcm as you suggested, and later I will write back whether it helped or not.
AMSURLSession: [AEE04261] Task completed with error = Error Domain=AMSErrorDomain Code=301 "Invalid Status Code" UserInfo={NSLocalizedFailureReason=The response has an invalid status code, AMSURL=https://sandbox.itunes.apple.com/commerce /messages/app/inbox?bundleId=com.realconstruction.ios&guid=...........&status=1, AMSStatusCode=412, NSLocalizedDescription=Invalid Status Code}
Take a look at this: https://developer.apple.com/forums/thread/661351?page=3
Take a look at this: https://developer.apple.com/forums/thread/661351?page=3
It turned out that this error does not apply to us. It disappeared when I switched from TestFlight to the version from the Appstore.
Therefore, the question remains open, I do not understand why the first notification does not come after the application is closed. But all subsequent notifications successfully reach, although the application still remains completely closed. I didn't notice any other errors in the console.
Can you test this behavior for yourself? The notification is sent from the server, here is the configuration:
{ data: { content: JSON.stringify({ id: id, channelKey: 'real_construction_channel_key', title: title, body: desc, icon: 'resource://drawable/push', color: '#0774EA', showWhen: true, payload: payload ? payload : {}, }), }, android: { priority: "high", }, apns: { payload: { aps: { contentAvailable: true, }, }, headers: { "apns-push-type": "background", // Must be
5
whencontentAvailable
is set to true. "apns-priority": "5", "apns-topic": "com.realconstruction.ios", }, }, tokens: tokens, content_available: true, priority: "high", }
"apns": {
"payload": {
"aps": {
"contentAvailable": true,
},
},
"headers": {
"apns-push-type": "background",
// Must be 5 when contentAvailable is set to true.
"apns-priority": "5",
"apns-topic": "com.realconstruction.ios",
},
},
This can be problematic. as you're using your push as a silent mode with background
and contentAvailable
. This makes your push be handle as background processing and suffer for some execution restrictions. You gonna do this instead:
{
tokens: tokens,
mutable_content: true,
priority: "high",
notification: {
title: title,
body: desc,
},
data: {
content: JSON.stringify({
id: id,
channelKey: 'real_construction_channel_key',
title: title,
body: desc,
icon: 'resource://drawable/push',
color: '#0774EA',
showWhen: true,
payload: payload ? payload : {},
}),
},
}
That's why i created the FCM addon plugin, this way you can use normal push notifications and they are more reliable than silent ones.
But if we add a block
notification: {
title: title,
body:desc
}
then the app will show 2 notifications. The first is from firebase and the second is from awesome. This behavior has been seen on Android. Because I am processing the content through createNotificationFromJsonData. At least that's how it used to be. That's why I use silent notification.
In addition, quick buttons (actionButtons) will not work on ios if you send a notification with a block
notification: {
title: title,
body:desc
}
But if we add a block notification: { title: title, body:desc } then the app will show 2 notifications. The first is from firebase and the second is from awesome. This behavior has been seen on Android. Because I am processing the content through createNotificationFromJsonData. At least that's how it used to be. That's why I use silent notification.
This is a sign that youre using firebase_messaging, right?
This is a sign that youre using firebase_messaging, right?
Yes. So far, we have the old implementation in the code. Is this fixed in awesome_notifications_fcm?
Yes, now, thanks to the FCM plugin, this type of push notification is fully supported. Also make sure you use the latest version of all three plugins and follow these steps to properly configure your project.
🛠Getting Started https://github.com/rafaelsetragni/awesome_notifications_fcm#-getting-started
First, as a good practice, I recommend that you create a backup copy or switch to a different branch to make such big changes to your project.
Ok. I will try and tell you later the result
This issue was automatically closed due inactivity, but can be reopened at any time.
1 - Describe the bug
Hello!
I send a notification to iOS, it arrives successfully, I click on it and the application opens. Then I close the app with a swipe up and try to send a new notification, but it doesn't get delivered. Then I hit submit again (third notification) and it's successfully received.
That is, after clicking on a notification and closing the application, the next notification will not be delivered.
Tell me what could be the problem?
2 - Provide us as much information as possible
3 - How To Reproduce the Error
4 - Expected behavior
I expect that after clicking on a notification and closing the app, the next sent notification will also be delivered.
5 - Screenshots
6 - Additional context
awesome_notifications: ^0.7.2 firebase_messaging: ^13.1.0