-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
plokko
committed
Jul 10, 2018
1 parent
e71849e
commit 6837fb5
Showing
4 changed files
with
54 additions
and
20 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/FCM/Message/ApnsAlert.php → src/FCM/Message/Apns/ApnsAlert.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Plokko\Firebase\FCM\Message; | ||
namespace Plokko\Firebase\FCM\Message\Apns; | ||
|
||
use JsonSerializable; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
namespace Plokko\Firebase\FCM\Message\Apns; | ||
|
||
use JsonSerializable; | ||
|
||
/** | ||
* ApnsConfig payload | ||
* @package Plokko\Firebase\FCM\Message | ||
* @see https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1 | ||
* | ||
* @property-read ApsData $aps | ||
*/ | ||
class ApnsPayload implements JsonSerializable | ||
{ | ||
private | ||
/** @var ApsData */ | ||
$aps; | ||
private | ||
/**@var array Custom data for app (acme)**/ | ||
$app_data=[]; | ||
|
||
function __get($k) | ||
{ | ||
if($k==='aps'){ | ||
if(!$this->aps) | ||
$this->aps = new ApsData(); | ||
return $this->aps; | ||
} | ||
return array_key_exists($k,$this->app_data)?$this->app_data[$k]:null; | ||
} | ||
|
||
function __set($k, $v) | ||
{ | ||
if($k==='aps'){ | ||
throw new \InvalidArgumentException('aps is a reserved keyword'); | ||
} | ||
$this->app_data[$k] = $v; | ||
} | ||
|
||
public function jsonSerialize() | ||
{ | ||
return array_filter(array_merge($this->app_data,[ | ||
'aps'=>$this->aps, | ||
])); | ||
} | ||
} |
25 changes: 6 additions & 19 deletions
25
src/FCM/Message/ApnsPayload.php → src/FCM/Message/Apns/ApsData.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters