web-push-libs / web-push-php

Web Push library for PHP
MIT License
1.68k stars 295 forks source link

Make $supportedContentEncodings publicly available or implement encoding negotiation #381

Open MarkoNV opened 7 months ago

MarkoNV commented 7 months ago

This is feature request:

Minishlink\WebPush\Subscription in constructor checks $contentEncoding against local variable. That prevents setting unsupported value, but there is no way for developer to easily find encoding which is supported by both browser and library.

Some developers still use default value 'aesgcm', other pass first supported encoding if browser supports PushManager.supportedContentEncodings. In first case, code will fail if some browser drop support for 'aesgcm' and in second case, it will fail if browser implement and prefer new encoding.

I have two possible solutions for this: 1.) Make it protected/private property with public getter. That way, developer can make encoding negotiation with browser externally.

2.) Make negotiation internally in constructor (which would require changing signature) or in create() method by accepting array of encodings, taking first supported one from array.

P.S. Sorry for closing and reopening, I missclicked submit, so closed while completing text.