Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add localized title and arguments #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions ApnsPHP/Message/Custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class ApnsPHP_Message_Custom extends ApnsPHP_Message
protected $_aLocArgs; /**< @type array Variable string values to appear in place of the format specifiers in loc-key. */
protected $_sLaunchImage; /**< @type string The filename of an image file in the application bundle. */
protected $_sTitle; /**< @type string The title of an short looknotification displayed on Apple Watch. */

protected $_sTitleLocKey; /**< @type string The key to a title string in the Localizable.strings file displayed on Apple Watch */
protected $_aTitleLocArgs; /**< @type array Variable string values to appear in place of the format specifiers in title-loc-key. */
/**
* Set the "View" button title.
*
Expand Down Expand Up @@ -100,7 +101,7 @@ public function setLocArgs($aLocArgs)
* Get the variable string values to appear in place of the format specifiers
* in loc-key.
*
* @return @type string The variable string values.
* @return @type array The variable string values.
*/
public function getLocArgs()
{
Expand Down Expand Up @@ -157,6 +158,49 @@ public function getTitle()
return $this->_sTitle;
}

/**
* Set the key to a title string in the Localizable.strings file for the current localization.
*
* The key string can be formatted with %@ and %n$@ specifiers to take the variables specified in the title-loc-args array.
*
* @param $sTitleLocKey @type string The alert-message string.
*/
public function setTitleLocKey($sTitleLocKey)
{
$this->_sTitleLocKey = $sTitleLocKey;
}

/**
* Get the title string in Localizable.strings file.
*
* @return @type string The title string.
*/
public function getTitleLocKey()
{
return $this->_sTitleLocKey;
}

/**
* Set the variable string values to appear in place of the format specifiers
* in title-loc-key.
*
* @param $aTitleLocArgs @type array The variable string values.
*/
public function setTitleLocArgs($aTitleLocArgs)
{
$this->_aTitleLocArgs = $aTitleLocArgs;
}

/**
* Get the variable string values to appear in place of the format specifiers
* in title-loc-key.
*
* @return @type array The variable string values.
*/
public function getTitleLocArgs()
{
return $this->_aTitleLocArgs;
}
/**
* Get the payload dictionary.
*
Expand Down Expand Up @@ -192,6 +236,12 @@ protected function _getPayload()
if (isset($this->_sTitle)) {
$aPayload['aps']['alert']['title'] = (string)$this->_sTitle;
}
if (isset($this->_sTitleLocKey)) {
$aPayload['aps']['alert']['title-loc'] = (string)$this->_sTitleLocKey;
}
if (isset($this->_aTitleLocArgs)) {
$aPayload['aps']['alert']['title-loc-args'] = $this->_aTitleLocArgs;
}

return $aPayload;
}
Expand Down