File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -213,16 +213,18 @@ private function prepareAndSend(array $notifications)
213
213
}
214
214
215
215
// if GCM or FCM url
216
- if ( substr ($ endpoint , 0 , Utils:: safe_strlen (self ::GCM_URL )) === self ::GCM_URL
217
- || substr ($ endpoint , 0 , Utils:: safe_strlen (self ::FCM_URL )) === self ::FCM_URL ) {
216
+ $ isGCM = substr ($ endpoint , 0 , strlen (self ::GCM_URL )) === self ::GCM_URL ;
217
+ if ( $ isGCM || substr ($ endpoint , 0 , strlen (self ::FCM_URL )) === self ::FCM_URL ) {
218
218
if (array_key_exists ('GCM ' , $ this ->auth )) {
219
219
$ headers ['Authorization ' ] = 'key= ' .$ this ->auth ['GCM ' ];
220
- } else {
220
+ } elseif ($ isGCM ) {
221
+ // FCM doesn't need an API key, it's optional if you're using VAPID
221
222
throw new \ErrorException ('No GCM/FCM API Key specified. ' );
222
223
}
223
224
}
224
- // if VAPID
225
- elseif (array_key_exists ('VAPID ' , $ this ->auth )) {
225
+
226
+ // if VAPID (GCM doesn't support it but FCM does)
227
+ if (array_key_exists ('VAPID ' , $ this ->auth ) && !$ isGCM ) {
226
228
$ vapid = $ this ->auth ['VAPID ' ];
227
229
228
230
$ audience = parse_url ($ endpoint , PHP_URL_SCHEME ).'// ' .parse_url ($ endpoint , PHP_URL_HOST );
You can’t perform that action at this time.
0 commit comments