@@ -82,7 +82,7 @@ void GetMissedServiceWorkerEvents()
8282 ServiceWorker_OnPush ( e . JSRefMove < MissedPushEvent > ( ) ) ;
8383 break ;
8484 case "pushsubscriptionchange" :
85- ServiceWorker_OnPushSubscriptionChange ( e . JSRefMove < PushSubscriptionChangeEvent > ( ) ) ;
85+ ServiceWorker_OnPushSubscriptionChange ( e . JSRefMove < MissedPushSubscriptionChangeEvent > ( ) ) ;
8686 break ;
8787 case "sync" :
8888 ServiceWorker_OnSync ( e . JSRefMove < MissedSyncEvent > ( ) ) ;
@@ -160,7 +160,7 @@ void ServiceWorker_OnNotificationClick(NotificationEvent e)
160160 /// <summary>
161161 /// Occurs when a push subscription has been invalidated, or is about to be invalidated (e.g. when a push service sets an expiration time).
162162 /// </summary>
163- protected virtual void ServiceWorker_OnPushSubscriptionChange ( PushSubscriptionChangeEvent e ) { }
163+ protected virtual Task ServiceWorker_OnPushSubscriptionChangeAsync ( PushSubscriptionChangeEvent e ) => Task . CompletedTask ;
164164 /// <summary>
165165 /// Triggered when a call to SyncManager.register is made from a service worker client page. The attempt to sync is made either immediately if the network is available or as soon as the network becomes available.
166166 /// </summary>
@@ -214,6 +214,29 @@ void ServiceWorker_OnInstall(ExtendableEvent e)
214214 e . WaitUntil ( ServiceWorker_OnInstallAsync ( e ) ) ;
215215 }
216216 }
217+ void ServiceWorker_OnPushSubscriptionChange ( PushSubscriptionChangeEvent e )
218+ {
219+ if ( e is IMissedExtendableEvent missedEvent )
220+ {
221+ Async . Run ( async ( ) =>
222+ {
223+ try
224+ {
225+ await ServiceWorker_OnPushSubscriptionChangeAsync ( e ) ;
226+ missedEvent . WaitResolve ( ) ;
227+ }
228+ catch ( Exception ex )
229+ {
230+ Console . Error . WriteLine ( ex . ToString ( ) ) ;
231+ missedEvent . WaitReject ( ) ;
232+ }
233+ } ) ;
234+ }
235+ else
236+ {
237+ e . WaitUntil ( ServiceWorker_OnPushSubscriptionChangeAsync ( e ) ) ;
238+ }
239+ }
217240 void ServiceWorker_OnActivate ( ExtendableEvent e )
218241 {
219242 if ( e is MissedExtendableEvent missedEvent )
0 commit comments