Skip to content

Commit eb9ac33

Browse files
committed
Additional FCM options for FcmMessageBuilder
1 parent dea6381 commit eb9ac33

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

src/FcmMessageBuilder.php

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ function notificationTitle($title){
6666
return $this;
6767
}
6868

69+
/**
70+
* Set the notification sound (Android/IOS);
71+
* set to "default" for default sound, null to remove
72+
* @param string $sound
73+
* @return $this
74+
*/
75+
function notificationSound($sound){
76+
$this->message->android->notification->sound = $sound;
77+
return $this;
78+
}
79+
6980
/**
7081
* Set the notification body
7182
* @param string $body
@@ -79,18 +90,48 @@ function notificationBody($body){
7990
/**
8091
* Set the message priority
8192
* @param 'high'|"normal" $priority
82-
* @return FcmMessageBuilder
93+
* @return $this
8394
*/
8495
function priority($priority){
8596
if($priority!=='high' && $priority!=='normal')
8697
throw new \InvalidArgumentException('Invalid priority value!');
8798
$this->message->android->setPriority($priority);
8899
return $this;
89100
}
101+
/**
102+
* Set the message tag (Android/IOS)
103+
* @param string $tag
104+
* @return $this
105+
*/
106+
function notificationTag($tag){
107+
$this->message->android->notification->tag = $tag;
108+
return $this;
109+
}
110+
111+
112+
/**
113+
* Set Android message options with a callback
114+
* @param Closure(\Plokko\Firebase\FCM\Message\AndroidNotification) $closure
115+
* @return $this
116+
*/
117+
function setAndroidNotification($closure){
118+
$closure($this->android->notification);
119+
return $this;
120+
}
121+
122+
/**
123+
* Set Android message options with a callback
124+
* @param Closure(\Plokko\Firebase\FCM\Message\AndroidConfig) $closure
125+
* @return $this
126+
*/
127+
function setAndroidConfig($closure){
128+
$closure($this->android);
129+
return $this;
130+
}
90131

91132
/**
92133
* Set high priority
93-
* @return FcmMessageBuilder
134+
* @return $this
94135
*/
95136
function highPriority(){
96137
$this->priority('high');
@@ -99,7 +140,7 @@ function highPriority(){
99140

100141
/**
101142
* Set normal priority
102-
* @return FcmMessageBuilder
143+
* @return $this
103144
*/
104145
function normalPriority(){
105146
$this->priority('normal');
@@ -109,7 +150,7 @@ function normalPriority(){
109150
/**
110151
* Set the time to live of the message
111152
* @param string $ttl TTL as a string (ex. '14.5s')
112-
* @return FcmMessageBuilder
153+
* @return $this
113154
*/
114155
function ttl($ttl){
115156
$this->message->android->ttl($ttl);

0 commit comments

Comments
 (0)