Hello, I would like to implement the function of unsubscribe FCM topics that I was subscribing to when I received a specific push from the server.
It was implemented through "willPresent" when the app was running, but I don't know how to do it when the app is not running.
I activated the 'Background fetch' and 'Remote Notifications' options for now.
const message = {
notification: {
title: 'FCM Topic UnSubscribe',
body: 'TestTestTest',
},
data: {
payload: JSON.stringify(payloadJson)
},
apns: {
payload: {
aps: {
sound: 'default',
'mutable-content': 1,
'content-available': 1
}
}
},
topic: 'unsubscribe_topic',
};
Test node code
Payload contains the type of topic you want to unsubscribe from.
And I added a function to receive push from didReceiveRemoteNotification and handle logic.
But this doesn't work.
Does Remote Notification (content-available) not work in iOS's Not running and Suspended state??
I'm also using the Notification Service Extension, is this related to it?
content-available
notifications are heavily throttled, and are not suitable to use if you expect to run code every time one is sent/ While you can expect 1-2 content-available
notifications to arrive at your app every hour in suspended state, if the user has terminated the app, you will receive none until they launch it again. Overall, content-available
notifications are not suitable if you need to process every one that is sent.
mutable-content
, on the other hand is related to the Notification Service Extension, and will cause the NSE to execute for every received notification as long as your notification has visible content.
In your payload example I see there is a mutable-content
entry in the aps{}
dictionary, but no visible content. I cannot say whether the notification dictionary you send to FCM translates into actual aps alert dictionary with visible content or not, but if it does, the NSE will be launched for these notifications.
Argun Tekant / DTS Engineer / Core Technologies