@@ -12,6 +12,7 @@ class FcmMessage implements Message
1212{
1313 use Macroable;
1414
15+
1516 /**
1617 * Create a new message instance.
1718 */
@@ -28,6 +29,7 @@ public function __construct(
2829 //
2930 }
3031
32+
3133 /**
3234 * Create a new message instance.
3335 */
@@ -36,6 +38,7 @@ public static function create(...$args): static
3638 return new static (...$ args );
3739 }
3840
41+
3942 /**
4043 * Set the message name.
4144 */
@@ -46,9 +49,7 @@ public function name(?string $name): self
4649 return $ this ;
4750 }
4851
49- /**
50- * Set the message token.
51- */
52+
5253 public function token (?string $ token ): self
5354 {
5455 $ this ->token = $ token ;
@@ -66,22 +67,17 @@ public function topic(?string $topic): self
6667 return $ this ;
6768 }
6869
69- /**
70- * Set the message condition.
71- */
70+
7271 public function condition (?string $ condition ): self
7372 {
7473 $ this ->condition = $ condition ;
7574
7675 return $ this ;
7776 }
7877
79- /**
80- * Set the message data, or throw exception if data is not an array of strings.
81- */
8278 public function data (?array $ data ): self
8379 {
84- if (! empty (array_filter ($ data , fn ($ value ) => ! is_string ($ value )))) {
80+ if (! empty (array_filter ($ data , fn ($ value ) => ! is_string ($ value )))) {
8581 throw new InvalidArgumentException ('Data values must be strings. ' );
8682 }
8783
@@ -90,36 +86,62 @@ public function data(?array $data): self
9086 return $ this ;
9187 }
9288
89+
90+ public function custom (?array $ custom = []): self
91+ {
92+ $ this ->custom = $ custom ;
93+
94+ return $ this ;
95+ }
96+
97+
9398 /**
94- * Set additional custom message data .
99+ * Set "android" specific custom options .
95100 */
96- public function custom (? array $ custom ): self
101+ public function android ( array $ options = [] ): self
97102 {
98- $ this ->custom = $ custom ;
103+
104+ $ this ->custom ([
105+ ...$ this ->custom ,
106+ 'android ' => $ options ,
107+ ]);
99108
100109 return $ this ;
101110 }
102111
112+
113+
103114 /**
104- * Set the message notification.
115+ * Set APNs-specific custom options for iOS.
116+ * Set APNs-specific custom options for iOS.
105117 */
118+ public function ios (array $ options = []): self
119+ {
120+ $ this ->custom ([
121+ ...$ this ->custom ,
122+ 'apns ' => $ options ,
123+ 'apns ' => $ options ,
124+ ]);
125+
126+ return $ this ;
127+ }
128+
129+
106130 public function notification (Notification $ notification ): self
107131 {
108132 $ this ->notification = $ notification ;
109133
110134 return $ this ;
111135 }
112136
113- /**
114- * Set the message Firebase Messaging client instance.
115- */
116137 public function usingClient (Messaging $ client ): self
117138 {
118139 $ this ->client = $ client ;
119140
120141 return $ this ;
121142 }
122143
144+
123145 public function toArray ()
124146 {
125147 return array_filter ([
@@ -133,6 +155,7 @@ public function toArray()
133155 ]);
134156 }
135157
158+
136159 /**
137160 * @return mixed
138161 */
0 commit comments