File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ class Fcm
2020
2121 protected $ serverKey ;
2222
23+ protected $ responseLogEnabled = false ;
24+
2325 public function __construct ($ serverKey )
2426 {
2527 $ this ->serverKey = $ serverKey ;
@@ -73,11 +75,18 @@ public function timeToLive($timeToLive)
7375
7476 return $ this ;
7577 }
76-
78+
7779 public function setPackage ($ package )
7880 {
7981 $ this ->package = $ package ;
80-
82+
83+ return $ this ;
84+ }
85+
86+ public function enableResponseLog ($ enable = true )
87+ {
88+ $ this ->responseLogEnabled = $ enable ;
89+
8190 return $ this ;
8291 }
8392
@@ -117,7 +126,13 @@ public function send()
117126 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
118127 curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , CURL_IPRESOLVE_V4 );
119128 curl_setopt ($ ch , CURLOPT_POSTFIELDS , json_encode ($ payloads ));
120- $ result = json_decode (curl_exec ($ ch ), true );
129+ $ response = curl_exec ($ ch );
130+
131+ if ($ this ->responseLogEnabled ) {
132+ logger ('laravel-fcm ' , ['response ' => $ response ]);
133+ }
134+
135+ $ result = json_decode ($ response , true );
121136 curl_close ($ ch );
122137
123138 return $ result ;
You can’t perform that action at this time.
0 commit comments