Gcm ios push notifications in background fail - ios

I can receive push notifications when my app is in foreground but it is not working in background.
When I send the json has this form:
{
"data":{"message":"test ios push notification"},
"time_to_live":604800,
"registration_ids":["key...."],
"collapse_key":"GCM Notifications",
"content_available":1,
"priority":"high"
}
In my application I get in foreground (nothing in background):
{
aps = {
"content-available" = 1;
};
"gcm.message_id" = " whatever ";
message = "test ios push notification";
}
I think that the problem is around content_available but I dont know why I send content_available and the return is content-available. Is this a normal conversion?

SOLVED!
Me bad, I forget to enable it in target -> Capabilities section:

Related

Notification delegate not being called when app is in background when notification is received

I am using firebase cloud messaging to send push notifications to our iOS application. When the application is in the foreground everything works fine.
The problem is when i send the app to the background and then send a notification.
I expect the following delegate to be called, but it is not:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],fetchCompletionHandler completionHandler: #escaping (UIBackgroundFetchResult)-> Void) {
I have ticked the "remote notifications" background mode in my apps signing & capabilities tab.
The payload i send to firebase looks like this:
{"to":"--TOKEN--",
"priority":"high",
"content_available":true,
"mutable_content": true,
"notification":
{"body":"Test Notification",
"title":"New Notification",
"sound":"default",
"click_action":"notification"
}
}
This payload is sent to firebase via https://fcm.googleapis.com/fcm/send
When i click an notification it is then processed, and i can see the apns version i receive looks like this:
[AnyHashable("google.c.sender.id"): 8xxxxxxxx, AnyHashable("gcm.message_id"): 1xxxxxxxxxx, AnyHashable("google.c.a.e"): 1, AnyHashable("google.c.fid"): fxxxxxxxxx, AnyHashable("aps"): {
alert = {
body = "Test Notification";
title = "New Notification";
};
category = feedback;
"content-available" = 1;
"mutable-content" = 1;
sound = default;
}]
I am not sure why content-available and mutable-content appear in quotes? I know firebase convers its payload to apns format, is there something wrong here?
I want the delegate to be called so that i can execute some code to maintain various data items, so it is important that i can run some code when my app is in the background and a notification is received.
I am not sure what config i am missing as everything i read seems to say this is all i need to do?

react native push notification not display when app in background on ios

I have react native application until now I used react-native-firebase version 5.5.6 (https://www.npmjs.com/package/react-native-firebase/v/5.5.6) to recived push notification and every work fine in android and ios.
now i upgrade to react-native-firebase version 11.1.2 and react-native-firebase/messaging version 11.1.2.
in android the notification work fine in all app state (foreground, background, closed)
in ios when app in foreground the notification recived fine but in in background or closed app the notification not showing
I mark the remote notification and fetch notification in background modes in xcode
when the in foreground and i received notification this is json i received
{
aps = {
alert = {
body = "\nCat. No.: 34612\nAddress: \U05d1\U05e0\U05d9\U05d9\U05df \U05e2\U05d9\U05e8\U05d9\U05d9\U05d4 \U05d1\nFloor: 2\nReported about: Intercoms \nStatus: Your call has been received\n Description: check\n Full name: \U05d2\U05dc\U05d7\U05d1\U05d7 \U05dc\U05d1\U05d9\U05d0\U05d7\U05d2\U05d7";
title = "New message about a service call";
};
badge = 2;
"content-available" = 1;
"mutable-content" = 1;
};
"custom_notification" = "{\"title\":\"New message about a service call\",\"body\":\"\\nCat. No.: 34612\\nAddress: \U05d1\U05e0\U05d9\U05d9\U05df \U05e2\U05d9\U05e8\U05d9\U05d9\U05d4 \U05d1\\nFloor: 2\\nReported about: Intercoms \\nStatus: Your call has been received\\n Description: check\\n Full name: \U05d2\U05dc\U05d7\U05d1\U05d7 \U05dc\U05d1\U05d9\U05d0\U05d7\U05d2\U05d7\",\"show_in_foreground\":true,\"icon\":\"push_notification\",\"sound\":\"default\"}";
deepLink = "https://darimpo-test.appspot.com/#openApplication?serviceCallId=34612&taskPostId=151288";
"fcm_options" = {
image = "https://storage.googleapis.com/download/storage/v1/b/darimpo_test_images/o/8551.jpg?generation=1615666155330439&alt=media";
};
"gcm.message_id" = 1616606515037965;
"google.c.a.e" = 1;
"show_in_foreground" = "{\"title\":\"New message about a service call\",\"body\":\"\\nCat. No.: 34612\\nAddress: \U05d1\U05e0\U05d9\U05d9\U05df \U05e2\U05d9\U05e8\U05d9\U05d9\U05d4 \U05d1\\nFloor: 2\\nReported about: Intercoms \\nStatus: Your call has been received\\n Description: check\\n Full name: \U05d2\U05dc\U05d7\U05d1\U05d7 \U05dc\U05d1\U05d9\U05d0\U05d7\U05d2\U05d7\",\"show_in_foreground\":true,\"icon\":\"push_notification\",\"sound\":\"default\"}";
}
maybe you now why is not working for me
thank you

Xamarin IOS Push Killed app

Push =>
{{
aps = {
alert = {
"loc-args" = (
);
"loc-key" = "new_chat";
};
"content-available" = 1;
id = 3;
message = Aaa;
sound = default;
subject = "new_chat";
type = chat;
};
}}
When the application is killed and I receive a push notification it is shown with the text "new_chat". How can I change it to another text?
Assuming you are targeting iOS 10+, you can add a Notification Services extension app (UNNotificationServiceExtension) to your app bundle.
modifies the content of a remote notification before it is delivered to the user.
In the DidReceiveNotificationRequest override, extract your content from the UNNotificationRequest and modify it and return it via the contentHandler provided.
Required reading to understand how/when the extension is used:
Modifying Content in Newly Delivered Notifications
Also:
Xamarin Docs: iOS Extensions in Xamarin.iOS
Apple docs: UNNotificationServiceExtension

Can't Get GCM Notification from background ios sdk

I can't get GCM notification from background, Although can receive it on foreground such as these:
{
aps = {
alert = {
body = fffff;
title = "\U067e\U06cc\U0627\U0645";
};
badge = 9;
sound = default;
};
"gcm.message_id" = "0:1448218309944532%075c2cd9075c2cd9";
}
Any help?
To get notifications in background, as per apple documentation
"Remote notifications" option needs to be enabled in Background modes under Capabilities in the target settings.
and normally when you receive any notification at that time application:didReceiveRemoteNotification: this method called.
and if you want to call this method in background, then you should sent a silent pushnotification. and for that you have to add content-available key with value 1 into the notification payload.
you JSON response contain that key like below example
{
aps = {
"content-available" : 1,
sound : ""
};
}

Push notification badge not updating in iOS 7.1 when app is closed or in background

{
aps = {
alert = "You have assigned 1 new task.";
badge = 1;
sound = "default"
};
}
The same JSON Payload is working in iOS 8+ but not in 7.1
Am I missing something here in payload?
I have checked for the notification settings and it's fine too.

Resources