-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See CHANGELOG for details - added Blazor interop for install notifica…
…tion
- Loading branch information
1 parent
5632f4d
commit babddbf
Showing
8 changed files
with
139 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Blazor.PWA.MSBuild.Tasks/Templates/ServiceWorker/sw_register-beforeinstallprompt.template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
window.addEventListener('beforeinstallprompt', function (e) { | ||
// Prevent Chrome 67 and earlier from automatically showing the prompt | ||
e.preventDefault(); | ||
// Stash the event so it can be triggered later. | ||
window.PWADeferredPrompt = e; | ||
|
||
showAddToHomeScreen(); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Blazor.PWA.MSBuild.Tasks/Templates/ServiceWorker/sw_register-installable-blazor.template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
| ||
function showAddToHomeScreen() { | ||
DotNet.invokeMethodAsync(blazorAssembly, blazorInstallMethod) | ||
.then(function () { }, function (er) { setTimeout(showAddToHomeScreen, 1000); }); | ||
} | ||
|
||
window.BlazorPWA = { | ||
installPWA: function () { | ||
if (window.PWADeferredPrompt) { | ||
window.PWADeferredPrompt.prompt(); | ||
window.PWADeferredPrompt.userChoice | ||
.then(function (choiceResult) { | ||
window.PWADeferredPrompt = null; | ||
}); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
#### 10/08/2019 | ||
#### 10/08/2019 - 13/08/2019 | ||
|
||
- Added new **Property** **`ServiceWorkerUpdateAlertText`** - used to change the default text in the "Update available alert". | ||
- Added new **Property** **`ServiceWorkerRegisterUpdateType`** - used to select the "Update available alert" type. | ||
- Added new **Property** **`ServiceWorkerRegisterUpdateTemplate`** - The name of the template file for the "update available" event. | ||
- Moved the "Updated available alert" to it's own template so we can have alternates | ||
- Added new **Property** **`ServiceWorkerRegisterInstallableType`** - used to select the "Installable PWA alert" type. | ||
- Added new **Property** **`ServiceWorkerRegisterInstallableTemplate`** - The name of the template file for the "Installable PWA alert" event. | ||
- Added new **Property** **`ServiceWorkerRegisterBeforeInstallPromptType`** - used to select the "Before Install Prompt" type. | ||
- Added new **Property** **`ServiceWorkerRegisterBeforeInstallPromptTemplate`** - The name of the template file for the "Before Install Prompt" event. | ||
- Moved the "Update available alert" to it's own template so we can have alternates | ||
- Moved the "Installable PWA alert" to it's own template so we can have alternates | ||
- Tidied up default install alert | ||
- Moved the "Before Install Prompt" to it's own template so we can have alternates | ||
- Tidied up default install alert a bit | ||
- Added new Installable PWA Alert type - "installable-blazor" which will call a Blazor static method, which is defined by: | ||
- **`ServiceWorkerBlazorAssembly`** which is used to define the Blazor Assembly namespace - defaults to the project name | ||
- **`ServiceWorkerBlazorInstallMethod`** which is used to define the Blazor method to call - defaults to 'PWAInstallable' | ||
- Updated README with Blazor interop example. | ||
|
||
#### 08/08/2019 Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters