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"}
Related
I am sending bulk push notifications to IOS users through APNS , and want to check the response of all the users , to check if any of them has uninstalled the app or not.
You can't be sure with Push Notifications about anything, Apple never guaranty the delivery of the Notification.
Your notification may never be delivered simply because when you send it he is in high mountain hiking with no data cover, or his phone is turned of, or he has killed your app from task manager (unless your send a VoIP notification), ecc.
I am developing application for IPhone in IBM Mobilefirst Platform 7.1 with Push Notification feature. I am sending the push notification based on the User ID.
Using adapter based authentiation, I am retrieving the User ID and subscribing to Push Notification based on the User ID.
The push notification behavior in my app:
Login and subscribe to push notification
Logout
Send Notification [ When app is in foreground ] - Successfully received and processed
Send Notification [ When app is in background ] - Successfully received and processed
Send Notification [ After killing the app running in background ] - Successfully received but can able to receive the notification content
and process it only after login ( i.e. pushNotificationInvoked
function is triggered with payload only after login)
Now, the point is, when the app is in foreground and background we can able to receive and process the notification regardless of the user is logged in or not. Then why do you need to login, on click of received notification when app is not running in foreground or background.
Is this the way MFP is handling the notification? or is there anything that I am missing here?
Thanks in advance.
Only once the user has logged-in, you can associate the notification with the user, without this you may display private data incoming with the notification to users who shouldn't receive it, since multiple users can potentially use the device.
I've looked into this for a while, but couldn't think of a way how to do this.
In WhatsApp and some other iOS chat apps the following happens.
Message receiver force-closes the app (app is not running in the background)
Sender sends a message.
Receiver receives the APNS push notification.
Sender sees the status as Delivered
What's interesting is, it can still do this when the device is turned off.
Let's say the receiver's device is turned off. Then the following happens.
Sender sends a message.
Sender sees status as Sent (to the server)
Receiver turns the phone on (but the app is not running in the background)
Receiver gets the push notification on device (but doesn't open it)
Sender sees the status as Delivered
GCM has the delivery status, and with APNS we can find the delivery status if the app is running in the background.
Since APNS doesn't have a delivery status feedback service, how does it know when a message has been received by the other end, even when the app is not running in the background?
APNS/GCM messages are received by special system service, not by application you are used. So when you turn on the phone - that service get messages and send new status to Apple/Google servers, and show notification to user.
Push Notification Service
I am now using OneSignal for push notification service to my iphone
Application State :
Let say my App is running in Background but the device is in Airplane Mode.
I send 3 messages from one signal "Test 1","Test 2","Test 3" in both "body" and "title" which apns offer.
When I switch my Airplane Mode off and back my device to online,only "Test 3" arrive and the remain "Test 1" & "Test 2" didn't appear.
Was it because of APNS notification limitation?I think it more less than 2KB.Did I do something wrong?I really do need a help to guide me.
HELP :
So,How to we handle many notification if the device is offline?
Right, APNS only stores one most recent message for devices that are unreachable. This is documented in the Apple Developer Library.
If APNs attempts to deliver a notification but the device is offline,
the notification is stored for a limited period of time, and
delivered to the device when it becomes available.
Only one recent notification for a particular app is stored. If
multiple notifications are sent while the device is offline, each new
notification causes the prior notification to be discarded. This
behavior of keeping only the newest notification is referred to as
coalescing notifications.
If the device remains offline for a long time, any notifications that
were being stored for it are discarded.
The most reliable way to ensure that background data is not lost is to instead store the data for each user on your server, then use background notifications to instruct your app to fetch the latest data from your server instead of fetching it from the notification metadata itself.
I'm working on getting background notifications to work on IOS with GCM - non-background notifications are already working.
In background notifications sometimes come and sometimes not.
I used conten_available = 1;
I successfully obtained a Registration Token and subscribe to topic:
Registration Token:
nU8ef5ZzonI:APA91bFaazXpqgI2wKTCujMaLLIZaKOmdpPAz2_WRc3V54d4eEI8p8VeAUZLwMAQ_8iaDDQ4XJAS44dFyIQkXcZ8cJjVdEGUEgnNOtrqxBKFHDTtPOUf2xT28vRprdStdVNzvrBFCQ3
Connected to GCM Sep 2 17:37:24 iPhones-iPad News[4201] : Already subscribed to /topics/news
But often in the backgrounds the application does not receive notification.
Or, the notification may come all at once old and new.
Why notification work so unstable?
You said "But often in the backgrounds the application does not receive notification. Or, the notification may come all at once old and new.".
Meaning not that they don't come, but they are delayed. Background pushes often are not immediate delivery and may take several hours.
If the user force quits the app they will not be delivered at all.
If you plug your iPhone into a power charger (or connect it to a computer via a charging usb cable) and try again you will most likely find they are delivered immediately. This is because starting with iOS8 background notification delivery is tied to power saving and hence why you will see them delayed and bunched together when they are delivered.