iOS - disappearing notifications - ios

I have a problem with disappearing notifications. On some devices, this happens:
I get several notifications with the same content
I click on the notification, the application consumes it
other messages (from my app) disappear from the notification center
My payload is:
{
"aps":{
"alert":{
"body":"some text"
},
"sound":"default",
"thread-id":"randomInteger"
},
"additionalContent":"1_755372#1946_0"
}
This only happens on some devices (probably iOS 16 only). Is this a system bug? Maybe there is some "push server" setting for these notifications?
I thought the problem was removing notifications from the group, so I entered a random thread-id for the test (so the system wouldn't treat them as one group). It's not helping

Related

Receiving Push Notification on the Iphone

Hello I'm stuck and I need help.
I have an iOS application build with Angular2 + Cordova + cordova-firebase-plugin + xcode.
I have setup the app on developers.apple.com and firebase.console website.
Now when I try to send a Notification message, I don't receive it on Iphone at all.
If the application is runing in the foreground, I see in the debug console that the notification was received, but it is not displayed on the Iphone.
Message from console:
Received data message: {
"collapse_key" = "com.example.app"
from = 793840040300;
notification = {
body = "example test notification message";
e = 1;
}
}
What I don't see here: notification title. (The notifications are working in Android, but not in iOS).
There were no any prompts about enabling the notifications (permissions prompt).
I trieed to setup APNS-FCM connectivity via .p12 Certificates and via .p8 Certificates (via the key). Boths atemmpts did not give me positive result...
One more moment:
IF the application is running in the background - I don't see the message in the console until I will open the app. When I open the app, the message appears in the console, if it was sent while the app was in foreground..
I viewed many different guides, but I didn't get any result.
I read that emulators does not support the push notifications, so I connected a real device via USB. And it behaves the same - no push notification received - only the message in the console.
Please, help me.
Make sure you are sending both the title and body in the payload. I had the issue (in Android) that when not sending the message item, the notification would not show up in the notifications bar. The same applies for iOS, but in this case, the variables are title and body.
If the right variables are not found in the payload, both Android, iOS and Windows Phone will consider it a background notification that is silently delivered to the app (once it's opened). Notifications will not wake an unloaded app, the app is launched by the notification item once it's selected from the notifications bar in this case.
Try sending the default payload from the documentation to test it:
{
"aps": {
"alert": { // alternatively just a string: "Your Message",
"title": "A short string describing the purpose of the notification",
"body": "The text of the alert message",
// localization of message is possible
"launch-image": "The filename of an image file in the app bundle, with or without the filename extension. The image is used as the launch image when users tap the action button or move the action slider"
},
"badge": 5, // Number to show at App icon
"content-available": "0", // configure background updates, see below
"category": "identifier", // Provide this key with a string value that represents the notification’s type
"thread-id": "id", // Provide this key with a string value that represents the app-specific identifier for grouping notifications
"sound": "default" // play default sound, or custom sound, see [iOS Sound](#sound-1) section
},
"custom_key1": "value1",
"custom_key2": "value2"
}
If this doesn't work, please include the entire content of the payload you are sending to APNS, from the server side.
Edit: make sure you are sending your payload fields in UTF-8 encoding to all push services.

Is there a way to receive notification when app is killed? That is when app is not working in foreground or background in iOS

I am using APNS push with content-type = 1. I receive the payload and fire using local notification.
this works fine in background and foreground mode
but when app is killed I get nothing.
what is the solution? I have seen people saying something about VOIP apps
but mine is not a VOIP app..
Some said to check Pushkin framework?
Any guidance?
Update
with this Json format I received notification when app was in killed state.. I checked on lower version 9.3 iOS.. have to check on iOS 11..
{
"aps": {
"content-available": 1,
"alert": "custom message ",
"badge": 1,
"sound": "solemn.wav"
},
"id": "55",
"data": "your data"
}
I don't think it can be done if your app is not a VOIP app. But, if you want to change the appearance of a push notification, you may want to look at the Notification Service Extension.
You have to include mutable-content flag as 1 in your payload inside aps. You cannot use content-type flag with this notification. Also, you have to show user something or the other after you have received the payload. Also, it is available in iOS 10 and above only.
Even with all these constraints, you can do some amazing things with this extension which were not possible earlier.
You can now show media attachment in the notification.
You can download small content or hit an API.
You can modify earlier sent push notification.
You can create a local notifcation center in your app.

iOS 10 Firebase Notification not showing on background

I´m having trouble on receiving push notifications (background) on a specific device running iOS 10. Other phones with iOS 9 are doing fine.
Although if I open the app the notification shows a banner that I implemented. Why does not show anything in background state?
Reading the firebase documentation something made me a little confused
According to a github firebase example on the following link https://github.com/firebase/quickstart-ios/blob/master/messaging/FCMSwift/AppDelegate.swift, there is a comment in the didReceiveRemoteNotification method that says:
// If you are receiving a notification message while your app is in
the background, // this callback will not be fired till the user taps
on the notification launching the application. // TODO: Handle data of
notification
So it my app is in background, does not apple do the whole thing to make that default iOS notification?
Does the content_available value interfere on this? I also send notification and data values.
Here is an example of the JSON I send:
{
"content_available": true,
"priority": "high",
"data": {
"post_id": "...",
"push_id": "..."
},
"notification": {
"title": "...",
"body": "..."
},
"registration_ids": ["xxxx"]
}
The expected behaviour would be:
App dead: the system will show the notification
App background: the system will show the notification and call the didReceiveRemoteNotification method.
App active: the system will NOT show de notification and call the didReceiveRemoteNotification method.
Right?
Your assumptions are correct except for number 2. There are several cases where apple will not call didReceiveRemoteNotification you even if you set the content_avaialable.
1) Device has low battery and is in power saver mode
2) App has "background app refresh" disabled
3) Other undocumented scenarios where apple decides not to wake up your app. Apple reserves the right to not deliver notifications for performance reasons.
Having said that, if the user taps the notification you will always get the payload in didReceiveRemoteNotification.

GCM not sending notification when App ios shutdown

I'm using GCM to send notifications to both android and IOS devices.
On IOS, the notifications are received while application is active or running in background.
However, when the application is down, no notification is received.
I tested by contacting directly APNS and the message is received. So the configuration on the device seems Ok.
Here is an example of a message sent to GCM:
{"notification":{
"badge":"4",
"body":"Test body",
"sound":"default",
"title":"Test title"
},
"collapse_key": "collapse_1",
"message_id": "1000003",
"content_available":true,
"to": "GCM TOKEN FOR DEVICE"
}
This message is received correctly when the application is in background but not when the app is shutdown.
I've sent the supposed message that should be sent to APNS, directly to APNS:
{"aps":{"alert":{"title":"Title","body":"Body"},"badge":5,
"sound":"default", "content-available":1}}
And the device receives this notification.
What am I missing? Is there a specific configuration to authorized GCM to send to APNS?
Thanks a lot, because I'm stuck.
Michael
Foreground pushes (i.e. those intended for the user) are always displayed. Background pushes (i.e. those intended for the app) are not sent to the app if the app has been killed.
Your push payload doesn't know what it is - its a mixture, it has a body/title/sound which a foreground push would have, but it also has content-available which is for background pushes.
Decide if your push should be a foreground or a background push and then chop out the unnecessary parts from your payload accordingly.
Also starting with iOS 8.1 (or 8.2 I forget which), background pushes will only instantly be delivered to the app if the app is in the foreground or if its in the background and the device is being charged (note, this included being connected to a mac via usb).
If the app is in the background and its not being charged then it might take several hours for the push to get delivered to the app.
If an iOS Application is killed from the switcher by the user, it will not receive push notifications. This is an OS thing that Apple deliberately implemented so there isn't a work around.
More info can be found here (login required): https://devforums.apple.com/message/873265#873265
we encountered this issue while trying to send messages to GCM topic, all android devices get the message correctly but not the ios ones where app is killed. Solved issue with sending message both in data and notification objects. Don't forget to put priority to high!!
Sample Json:
{"to":"/topics/xxx",
"collapse_key":"",
"data":{"message":"topic notification"},
"notification":{"body":"topicotification"},
"time_to_live":3600,
"content_available":true,
"priority":"high"}

IOS App implementing Google Cloud Messaging receives notifications only when active

I have implemented in my IOS app the new Google Cloud Messaging framework for handle push notifications. After implementation I'm able to receive push notifications only when App is active and in foreground. If App is closed or in background I didn't get the notification alert in my device. In the iOS notifications settings I see my app enabled to receive them.
I was having a similar problem where the app would receive a notification only if the app was running (foreground/background) and wouldn't receive anything if app was killed manually (terminated)
All I had to do to fix that was to add priority & content_available to the notification body when sending it (as #KayAnn pointed out)
Here's how it should look like :
{
"to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
"content_available" : true,
"priority": "high",
"notification" : {
"body" : "Winter is coming!",
"title" : "John Snow"
}
}
Keep in mind that I also have UIBackgroundModes: remote-notification in Info.plist.
Google documentations (in step 4) quotes:
If the GCMExample application is running in the foreground, you can
see the content of the notification printed to the Xcode debug
console; if the GCMExample app is in the background, you will receive
an APNS notification.
So in order to receive messages when the app is in background you have to register APNS as options as below as described here.
_registrationOptions = # {
kGGLInstanceIDRegisterAPNSOption: deviceToken,
kGGLInstanceIDAPNSServerTypeSandboxOption: #YES
};
EDIT:
There are few other things you need to do:
1) While publishing the app move to production certificate
In the JSON Payload:
2) Use "content_available": "true" OR
3) Set the "priority": "high"
EDIT:2
Using content_available and priority high in the same payload conflicts with Apple's recommendation (Apple docs). I have come across this during my testing. In such a scenario the message may be throttled.
Use either / or of these two parameters instead.
A Tip on working use-cases:
- content_available: use when you are sending data only and do not have other notification specific parameters like alert, badge, sound etc. This is because by default a content_available message is a silent push.
- Priority: high: Use it when you are sending a notification which should reach the users immediately, i.e time critical notifications such as game scores.

Resources