diff --git a/CHANGES.md b/CHANGES.md
index 1263df9..6ee2c7a 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,8 @@
- [1.0.0](https://github.com/Windos/BurntToast/releases/download/v1.0.0/BurntToast.zip)
+ - Breaking Change: Removed customizable AppId
+
- Breaking Change: Shoulder tap notification support has been removed
- Libraries: Microsoft.Windows.SDK.NET.Ref library bumped to 10.0.22621.28
diff --git a/Tests/Get-BTHistory.Tests.ps1 b/Tests/Get-BTHistory.Tests.ps1
index a3a8345..8298261 100644
--- a/Tests/Get-BTHistory.Tests.ps1
+++ b/Tests/Get-BTHistory.Tests.ps1
@@ -12,32 +12,5 @@ BeforeAll {
Describe 'Get-BTHistory' {
if ($PlatformAvailable) {
- Context 'valid AppId, one previous toast' {
- Mock Test-Path { $true } -ModuleName BurntToast -Verifiable -ParameterFilter {
- $Path -eq 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
- }
-
- It 'should not throw' {
- { Get-BTHistory } | Should -Not -Throw
- }
-
- It 'tested the correct path' {
- Assert-VerifiableMock
- }
- }
- }
-
- Context 'invalid AppId' {
- Mock Test-Path { $false } -ModuleName BurntToast -Verifiable -ParameterFilter {
- $Path -eq 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Script Checker'
- }
-
- It 'should throw' {
- { Get-BTHistory -AppId 'Script Checker' } | Should -Throw "The AppId Script Checker is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour."
- }
-
- It 'tested the correct path' {
- Assert-VerifiableMock
- }
}
}
diff --git a/Tests/New-BTAppId.Tests.ps1 b/Tests/New-BTAppId.Tests.ps1
deleted file mode 100644
index 24c2fb3..0000000
--- a/Tests/New-BTAppId.Tests.ps1
+++ /dev/null
@@ -1,52 +0,0 @@
-BeforeAll {
- if (Get-Module -Name 'BurntToast') {
- Remove-Module -Name 'BurntToast'
- }
-
- if ($ENV:BURNTTOAST_MODULE_ROOT) {
- Import-Module $ENV:BURNTTOAST_MODULE_ROOT -Force
- } else {
- Import-Module "$PSScriptRoot/../src/BurntToast.psd1" -Force
- }
-}
-
-Describe 'New-BTAppId' {
- Mock New-Item {} -ModuleName BurntToast
- Mock New-ItemProperty {} -ModuleName BurntToast
-
- Context 'executing when AppId already exists' {
- Mock Test-Path { $true } -ModuleName BurntToast -Verifiable -ParameterFilter {
- $Path -eq 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
- }
-
- New-BTAppId
-
- It 'tested the correct path' {
- Assert-VerifiableMock
- }
- It 'should not have called cmdlet: New-Item' {
- Assert-MockCalled New-Item -Time 0 -Exactly -Scope Context -ModuleName BurntToast
- }
- It 'should not have called cmdlet: New-Item' {
- Assert-MockCalled New-ItemProperty -Time 0 -Exactly -Scope Context -ModuleName BurntToast
- }
- }
-
- Context 'executing when AppId is unique' {
- Mock Test-Path { $false } -ModuleName BurntToast -Verifiable -ParameterFilter {
- $Path -eq 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Script Checker'
- }
-
- New-BTAppId -AppId 'Script Checker'
-
- It 'tested the correct path' {
- Assert-VerifiableMock
- }
- It 'should have called cmdlet: New-Item' {
- Assert-MockCalled New-Item -Time 1 -Exactly -Scope Context -ModuleName BurntToast
- }
- It 'should have called cmdlet: New-Item' {
- Assert-MockCalled New-ItemProperty -Time 1 -Exactly -Scope Context -ModuleName BurntToast
- }
- }
-}
diff --git a/Tests/New-BTColumn.Tests.ps1 b/Tests/New-BTColumn.Tests.ps1
index d2aebf3..f3ca01d 100644
--- a/Tests/New-BTColumn.Tests.ps1
+++ b/Tests/New-BTColumn.Tests.ps1
@@ -75,7 +75,7 @@ Describe 'New-BTColumn' {
}
It 'has consitent WhatIf response' {
- $Expected = 'What if: Performing the operation "Submit-BTNotification" on target "submitting: [ToastNotification] with AppId {1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe, Id , Sequence Number and XML: {Now Playing}{Title:}{Album:}{Artist:}{soft focus}{Birocratic}{beets 4 (2017)}".'
+ $Expected = 'What if: Performing the operation "Submit-BTNotification" on target "submitting: [ToastNotification] with Id , Sequence Number and XML: {Now Playing}{Title:}{Album:}{Artist:}{soft focus}{Birocratic}{beets 4 (2017)}".'
$Log | Should -Be $Expected
}
}
diff --git a/Tests/New-BurntToastNotification.Tests.ps1 b/Tests/New-BurntToastNotification.Tests.ps1
index dad86a2..40ad549 100644
--- a/Tests/New-BurntToastNotification.Tests.ps1
+++ b/Tests/New-BurntToastNotification.Tests.ps1
@@ -160,7 +160,7 @@ Describe 'New-BurntToastNotification' {
}
It 'has consitent WhatIf response' {
- $Expected = 'What if: Performing the operation "Submit-BTNotification" on target "submitting: [ToastNotification] with AppId {1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe, Id , Sequence Number and XML: {Default Notification}via Pester".'
+ $Expected = 'What if: Performing the operation "Submit-BTNotification" on target "submitting: [ToastNotification] with Id , Sequence Number and XML: {Default Notification}via Pester".'
$Log | Should -Be $Expected
}
}
diff --git a/src/BurntToast.psd1 b/src/BurntToast.psd1
index ce5c2e9..e593f76 100644
--- a/src/BurntToast.psd1
+++ b/src/BurntToast.psd1
@@ -12,7 +12,6 @@
FunctionsToExport = 'Get-BTHeader',
'Get-BTHistory',
'New-BTAction',
- 'New-BTAppId',
'New-BTAudio',
'New-BTBinding',
'New-BTButton',
diff --git a/src/Public/Get-BTHeader.ps1 b/src/Public/Get-BTHeader.ps1
index a8bb045..005339a 100644
--- a/src/Public/Get-BTHeader.ps1
+++ b/src/Public/Get-BTHeader.ps1
@@ -22,9 +22,6 @@ function Get-BTHeader {
[cmdletBinding(DefaultParametersetName = 'All',
HelpUri='https://github.com/Windos/BurntToast/blob/main/Help/Get-BTHeader.md')]
param (
- # Specifies the AppId of the 'application' or process that spawned the toast notification.
- [string] $AppId = $Script:Config.AppId,
-
# A string that uniquely identifies a toast notification to retrieve the Header for
[Parameter(Mandatory,
ParametersetName = 'ByToastId')]
@@ -43,9 +40,7 @@ function Get-BTHeader {
[string] $Id
)
- $HistoryParams = @{
- 'AppId' = $AppId
- }
+ $HistoryParams = @{}
if ($PSCmdlet.ParameterSetName -eq 'ByToastId') { $HistoryParams['UniqueIdentifier'] = $ToastUniqueIdentifier}
$HeaderIds = New-Object -TypeName "System.Collections.ArrayList"
diff --git a/src/Public/Get-BTHistory.ps1 b/src/Public/Get-BTHistory.ps1
index a63258d..79a05ee 100644
--- a/src/Public/Get-BTHistory.ps1
+++ b/src/Public/Get-BTHistory.ps1
@@ -26,9 +26,6 @@ function Get-BTHistory {
[cmdletBinding(HelpUri='https://github.com/Windos/BurntToast/blob/main/Help/Get-BTHistory.md')]
param (
- # Specifies the AppId of the 'application' or process that spawned the toast notification.
- [string] $AppId = $Script:Config.AppId,
-
# A string that uniquely identifies a toast notification. Submitting a new toast with the same identifier as a previous toast will replace the previous toast.
#
# This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast.
@@ -38,23 +35,19 @@ function Get-BTHistory {
[switch] $ScheduledToast
)
- if (!(Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\$AppId")) {
- throw "The AppId $AppId is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour."
+ if ($Script:ActionsSupported) {
+ Write-Warning -Message 'The output from this function in some versions of PowerShell is not useful. Unfortunately this is expected at this time.'
+ }
+
+ $Toasts = if ($ScheduledToast) {
+ [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::CreateToastNotifier().GetScheduledToastNotifications()
+ } else {
+ [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.GetHistory()
+ }
+
+ if ($UniqueIdentifier) {
+ $Toasts | Where-Object {$_.Tag -eq $UniqueIdentifier -or $_.Group -eq $UniqueIdentifier}
} else {
- if ($Script:ActionsSupported) {
- Write-Warning -Message 'The output from this function in some versions of PowerShell is not useful. Unfortunately this is expected at this time.'
- }
-
- $Toasts = if ($ScheduledToast) {
- [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).GetScheduledToastNotifications()
- } else {
- [Windows.UI.Notifications.ToastNotificationManager]::History.GetHistory($AppId)
- }
-
- if ($UniqueIdentifier) {
- $Toasts | Where-Object {$_.Tag -eq $UniqueIdentifier -or $_.Group -eq $UniqueIdentifier}
- } else {
- $Toasts
- }
+ $Toasts
}
}
diff --git a/src/Public/New-BTAppId.ps1 b/src/Public/New-BTAppId.ps1
deleted file mode 100644
index 238021e..0000000
--- a/src/Public/New-BTAppId.ps1
+++ /dev/null
@@ -1,53 +0,0 @@
-function New-BTAppId {
- <#
- .SYNOPSIS
- Creates a new AppId Registry Key.
-
- .DESCRIPTION
- The New-BTAppId function create a new AppId registry key in the Current User's Registery Hive. If the desired AppId is already present in the Registry then no changes are made.
-
- If no AppId is specified then the AppId specified in the config.json file in the BurntToast module's root directory is used.
-
- .INPUTS
- System.String
-
- You cannot pipe input to this cmdlet.
-
- .OUTPUTS
- None
-
- .EXAMPLE
- New-BTAppId
-
- This command creates an AppId registry key using the value specified in the BurntToast module's config.json file, which is 'BurntToast' by default.
-
- .EXAMPLE
- New-BTAppId -AppId 'Script Checker'
-
- This command create an AppId registry key called 'Script Checker.'
-
- .LINK
- https://github.com/Windos/BurntToast/blob/main/Help/New-BTAppId.md
- #>
-
- [CmdletBinding(SupportsShouldProcess = $true,
- HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/New-BTAppId.md')]
- param (
- # Specifies the new AppId. You can use any alphanumeric characters.
- #
- # Defaults to the AppId specified in the config.json file in the BurntToast module's root directoy if not provided.
- [ValidateNotNullOrEmpty()]
- [string] $AppId = $Script:Config.AppId
- )
-
- $RegPath = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings'
-
- if (!(Test-Path -Path "$RegPath\$AppId")) {
- if($PSCmdlet.ShouldProcess("creating: '$RegPath\$AppId' with property 'ShowInActionCenter' set to '1' (DWORD)")) {
- $null = New-Item -Path "$RegPath\$AppId" -Force
- $null = New-ItemProperty -Path "$RegPath\$AppId" -Name 'ShowInActionCenter' -Value 1 -PropertyType 'DWORD'
- }
- } else {
- Write-Verbose -Message 'Specified AppId is already present in the registry.'
- }
-}
diff --git a/src/Public/New-BurntToastNotification.ps1 b/src/Public/New-BurntToastNotification.ps1
index 0dc1c4e..741b623 100644
--- a/src/Public/New-BurntToastNotification.ps1
+++ b/src/Public/New-BurntToastNotification.ps1
@@ -83,9 +83,6 @@
#TODO: [ValidateScript({ Test-ToastImage -Path $_ })]
- # Specifies the AppId of the 'application' or process that spawned the toast notification.
- [string] $AppId = $Script:Config.AppId,
-
# Specifies the path to an image that will override the default image displayed with a Toast Notification.
[String] $AppLogo,
@@ -156,7 +153,7 @@
ParameterSetName = 'Sound-Button')]
[Microsoft.Toolkit.Uwp.Notifications.IToastButton[]] $Button,
- # Specify the Toast Header object created using the New-BTHeader function, for seperation/categorization of toasts from the same AppId.
+ # Specify the Toast Header object created using the New-BTHeader function, for seperation/categorization of toasts from the same application.
[Microsoft.Toolkit.Uwp.Notifications.ToastHeader] $Header,
# Specify one or more Progress Bar object created using the New-BTProgressBar function.
@@ -262,7 +259,6 @@
$ToastSplat = @{
Content = $Content
- AppId = $AppId
}
if ($UniqueIdentifier) {
diff --git a/src/Public/Remove-BTNotification.ps1 b/src/Public/Remove-BTNotification.ps1
index 392ca5a..4faa407 100644
--- a/src/Public/Remove-BTNotification.ps1
+++ b/src/Public/Remove-BTNotification.ps1
@@ -6,7 +6,7 @@ function Remove-BTNotification {
.DESCRIPTION
The Remove-BTNotification function removes toast notifications from the Action Center.
- If no parameters are specified, all toasts (for the default AppId) will be removed.
+ If no parameters are specified, all toasts (for the current application) will be removed.
Tags and Groups for Toasts can be found using the Get-BTHistory function.
@@ -30,9 +30,6 @@ function Remove-BTNotification {
SupportsShouldProcess = $true,
HelpUri = 'https://github.com/Windos/BurntToast/blob/main/Help/Remove-BTNotification.md')]
param (
- # Specifies the AppId of the 'application' or process that spawned the toast notification.
- [string] $AppId = $Script:Config.AppId,
-
# Specifies the tag, which identifies a given toast notification.
[Parameter(ParameterSetName = 'Individual')]
[string] $Tag,
@@ -48,28 +45,26 @@ function Remove-BTNotification {
)
if ($UniqueIdentifier) {
- if($PSCmdlet.ShouldProcess("Tag: $UniqueIdentifier, Group: $UniqueIdentifier, AppId: $AppId", 'Selectively removing notifications')) {
- [Windows.UI.Notifications.ToastNotificationManager]::History.Remove($UniqueIdentifier, $UniqueIdentifier, $AppId)
+ if($PSCmdlet.ShouldProcess("Tag: $UniqueIdentifier, Group: $UniqueIdentifier", 'Selectively removing notifications')) {
+ [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.Remove($UniqueIdentifier, $UniqueIdentifier)
}
- } elseif (!(Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\$AppId")) {
- Write-Warning -Message "The AppId $AppId is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour."
}
if ($Tag -and $Group) {
- if($PSCmdlet.ShouldProcess("Tag: $Tag, Group: $Group, AppId: $AppId", 'Selectively removing notifications')) {
- [Windows.UI.Notifications.ToastNotificationManager]::History.Remove($Tag, $Group, $AppId)
+ if($PSCmdlet.ShouldProcess("Tag: $Tag, Group: $Group", 'Selectively removing notifications')) {
+ [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.Remove($Tag, $Group)
}
} elseif ($Tag) {
- if($PSCmdlet.ShouldProcess("Tag: $Tag, AppId: $AppId", 'Selectively removing notifications')) {
- [Windows.UI.Notifications.ToastNotificationManager]::History.Remove($Tag, $AppId)
+ if($PSCmdlet.ShouldProcess("Tag: $Tag", 'Selectively removing notifications')) {
+ [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.Remove($Tag)
}
} elseif ($Group) {
- if($PSCmdlet.ShouldProcess("Group: $Group, AppId: $AppId", 'Selectively removing notifications')) {
- [Windows.UI.Notifications.ToastNotificationManager]::History.RemoveGroup($Group, $AppId)
+ if($PSCmdlet.ShouldProcess("Group: $Group", 'Selectively removing notifications')) {
+ [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.RemoveGroup($Group)
}
} else {
- if($PSCmdlet.ShouldProcess("AppId: $AppId", 'Clearing all notifications')) {
- [Windows.UI.Notifications.ToastNotificationManager]::History.Clear($AppId)
+ if($PSCmdlet.ShouldProcess("All", 'Clearing all notifications')) {
+ [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::History.Clear()
}
}
}
diff --git a/src/Public/Submit-BTNotification.ps1 b/src/Public/Submit-BTNotification.ps1
index ce51b7b..3c5b633 100644
--- a/src/Public/Submit-BTNotification.ps1
+++ b/src/Public/Submit-BTNotification.ps1
@@ -37,9 +37,6 @@
# This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast.
[string] $UniqueIdentifier,
- # Specifies the AppId of the 'application' or process that spawned the toast notification.
- [string] $AppId = $Script:Config.AppId,
-
# A hashtable that binds strings to keys in a toast notification. In order to update a toast, the original toast needs to include a databinding hashtable.
[hashtable] $DataBinding,
@@ -56,10 +53,6 @@
[scriptblock] $FailedAction
)
- if (!(Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\$AppId")) {
- Write-Warning -Message "The AppId $AppId is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour."
- }
-
if (-not $IsWindows) {
$null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]
}
@@ -166,7 +159,7 @@
}
}
- if($PSCmdlet.ShouldProcess( "submitting: [$($Toast.GetType().Name)] with AppId $AppId, Id $UniqueIdentifier, Sequence Number $($Toast.Data.SequenceNumber) and XML: $($Content.GetContent())")) {
+ if($PSCmdlet.ShouldProcess( "submitting: [$($Toast.GetType().Name)] with Id $UniqueIdentifier, Sequence Number $($Toast.Data.SequenceNumber) and XML: $($Content.GetContent())")) {
[Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::CreateToastNotifier().Show($Toast)
}
}
diff --git a/src/Public/Update-BTNotification.ps1 b/src/Public/Update-BTNotification.ps1
index 59a1804..e02c405 100644
--- a/src/Public/Update-BTNotification.ps1
+++ b/src/Public/Update-BTNotification.ps1
@@ -44,17 +44,10 @@
# This is useful when updating the progress of a process, using a progress bar, or otherwise correcting/updating the information on a toast.
[string] $UniqueIdentifier,
- # Specifies the AppId of the 'application' or process that spawned the toast notification.
- [string] $AppId = $Script:Config.AppId,
-
# A hashtable that binds strings to keys in a toast notification. In order to update a toast, the original toast needs to include a databinding hashtable.
[hashtable] $DataBinding
)
- if (!(Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\$AppId")) {
- Write-Warning -Message "The AppId $AppId is not present in the registry, please run New-BTAppId to avoid inconsistent Toast behaviour."
- }
-
if (-not $IsWindows) {
$null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]
}
@@ -73,7 +66,7 @@
$ToastData.SequenceNumber = $SequenceNumber
}
- if($PSCmdlet.ShouldProcess("AppId: $AppId, UniqueId: $UniqueIdentifier", 'Updating notification')) {
- [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($AppId).Update($ToastData, $UniqueIdentifier, $UniqueIdentifier)
+ if($PSCmdlet.ShouldProcess("UniqueId: $UniqueIdentifier", 'Updating notification')) {
+ [Microsoft.Toolkit.Uwp.Notifications.ToastNotificationManagerCompat]::CreateToastNotifier().Update($ToastData, $UniqueIdentifier, $UniqueIdentifier)
}
}
diff --git a/src/config.json b/src/config.json
index aee319c..3ffc2dd 100644
--- a/src/config.json
+++ b/src/config.json
@@ -1,4 +1,3 @@
{
- "AppId": "{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe",
"AppLogo": "\\Images\\BurntToast.png"
}