@@ -175,13 +175,15 @@ document.addEventListener("DOMContentLoaded", () => {
175
175
function push_sendSubscriptionToServer ( subscription , method ) {
176
176
const key = subscription . getKey ( 'p256dh' ) ;
177
177
const token = subscription . getKey ( 'auth' ) ;
178
+ const contentEncoding = ( PushManager . supportedContentEncodings || [ 'aesgcm' ] ) [ 0 ] ;
178
179
179
180
return fetch ( 'push_subscription.php' , {
180
181
method,
181
182
body : JSON . stringify ( {
182
183
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,
185
187
} ) ,
186
188
} ) . then ( ( ) => subscription ) ;
187
189
}
@@ -208,13 +210,15 @@ document.addEventListener("DOMContentLoaded", () => {
208
210
209
211
const key = subscription . getKey ( 'p256dh' ) ;
210
212
const token = subscription . getKey ( 'auth' ) ;
213
+ const contentEncoding = ( PushManager . supportedContentEncodings || [ 'aesgcm' ] ) [ 0 ] ;
211
214
212
215
fetch ( 'send_push_notification.php' , {
213
216
method : 'POST' ,
214
217
body : JSON . stringify ( {
215
218
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,
218
222
} )
219
223
} )
220
224
} )
0 commit comments