ApnsPHP
ApnsPHP copied to clipboard
Please add an option for silent push
/**
* The Push Notification Silent Message.
*/
class ApnsPHP_Message_Silent extends ApnsPHP_Message
{
/**
* Get the payload dictionary.
*
* @return @type array The payload dictionary.
*/
protected function _getPayload()
{
$aPayload = parent::_getPayload();
$aPayload['aps']['sound'] = '';
$aPayload['aps']['content-available'] = 1;
unset($aPayload['aps']['alert']);
return $aPayload;
}
}
already exists
$push->setSound(false);
$push->setBadge(false);
$push->setMessage(false);
ok but i think the "alert" key is still exists, empty but exists.. and my iOS developer say that is need to be unset in order for the silent push to work.
did this make any sense?
What is alert key? You can send silent push (only data for app) if you disable badge, message and sound in push.
the payload look like that: $payload['alert'] = '';
the alert key exists also when you:
$push->setSound(false);
$push->setBadge(false);
$push->setMessage(false);
and as i understand its not good when you want a silent push you need not include the 'alert' ket at all
It's a very old issue but still opened. So to clarify for people reading this, if you want to send a silent push you just need to set an empty string as a message. Although it's not the purpose here, but if you want the same effect with GCM you have a "dry_run" parameter that allows you to send silent pushes if you set it to true.
So to clarify for people reading this, if you want to send a silent push you just need to set an empty string as a message.
If you will set badge it would silent push, but also will update badge icon.