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
20
20
21
21
protected $ serverKey ;
22
22
23
+ protected $ responseLogEnabled = false ;
24
+
23
25
public function __construct ($ serverKey )
24
26
{
25
27
$ this ->serverKey = $ serverKey ;
@@ -73,11 +75,18 @@ public function timeToLive($timeToLive)
73
75
74
76
return $ this ;
75
77
}
76
-
78
+
77
79
public function setPackage ($ package )
78
80
{
79
81
$ this ->package = $ package ;
80
-
82
+
83
+ return $ this ;
84
+ }
85
+
86
+ public function enableResponseLog ($ enable = true )
87
+ {
88
+ $ this ->responseLogEnabled = $ enable ;
89
+
81
90
return $ this ;
82
91
}
83
92
@@ -117,7 +126,13 @@ public function send()
117
126
curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
118
127
curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , CURL_IPRESOLVE_V4 );
119
128
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 );
121
136
curl_close ($ ch );
122
137
123
138
return $ result ;
You can’t perform that action at this time.
0 commit comments