@@ -175,13 +175,15 @@ document.addEventListener("DOMContentLoaded", () => {
175175 function push_sendSubscriptionToServer ( subscription , method ) {
176176 const key = subscription . getKey ( 'p256dh' ) ;
177177 const token = subscription . getKey ( 'auth' ) ;
178+ const contentEncoding = ( PushManager . supportedContentEncodings || [ 'aesgcm' ] ) [ 0 ] ;
178179
179180 return fetch ( 'push_subscription.php' , {
180181 method,
181182 body : JSON . stringify ( {
182183 endpoint : subscription . endpoint ,
183- key : key ? btoa ( String . fromCharCode . apply ( null , new Uint8Array ( key ) ) ) : null ,
184- token : token ? btoa ( String . fromCharCode . apply ( null , new Uint8Array ( token ) ) ) : null
184+ publicKey : key ? btoa ( String . fromCharCode . apply ( null , new Uint8Array ( key ) ) ) : null ,
185+ authToken : token ? btoa ( String . fromCharCode . apply ( null , new Uint8Array ( token ) ) ) : null ,
186+ contentEncoding,
185187 } ) ,
186188 } ) . then ( ( ) => subscription ) ;
187189 }
@@ -208,13 +210,15 @@ document.addEventListener("DOMContentLoaded", () => {
208210
209211 const key = subscription . getKey ( 'p256dh' ) ;
210212 const token = subscription . getKey ( 'auth' ) ;
213+ const contentEncoding = ( PushManager . supportedContentEncodings || [ 'aesgcm' ] ) [ 0 ] ;
211214
212215 fetch ( 'send_push_notification.php' , {
213216 method : 'POST' ,
214217 body : JSON . stringify ( {
215218 endpoint : subscription . endpoint ,
216- key : key ? btoa ( String . fromCharCode . apply ( null , new Uint8Array ( subscription . getKey ( 'p256dh' ) ) ) ) : null ,
217- token : token ? btoa ( String . fromCharCode . apply ( null , new Uint8Array ( subscription . getKey ( 'auth' ) ) ) ) : null
219+ publicKey : key ? btoa ( String . fromCharCode . apply ( null , new Uint8Array ( subscription . getKey ( 'p256dh' ) ) ) ) : null ,
220+ authToken : token ? btoa ( String . fromCharCode . apply ( null , new Uint8Array ( subscription . getKey ( 'auth' ) ) ) ) : null ,
221+ contentEncoding,
218222 } )
219223 } )
220224 } )
0 commit comments