Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Summary] Error thrown when using -DismissedAction on Submit-BTNotification #122

Closed
pcgeek86 opened this issue Sep 29, 2020 · 3 comments
Assignees
Labels

Comments

@pcgeek86
Copy link

Steps to reproduce

$Context = New-BTContextMenuItem -Content 'AWS Console' -ActivationType Protocol -Arguments https://console.aws.amazon.com

$Action = New-BTAction -ContextMenuItems $Context

$Binding = New-BTBinding

$Visual = New-BTVisual -BindingGeneric $Binding

$Content = New-BTContent -Actions $Action -Visual $Visual 

Submit-BTNotification -Content $Content -DismissedAction { chrome }

Expected behavior

When I dismiss the toast, Chrome is launched.

Actual behavior

As soon as Submit-BTNotification runs, I get this error:

Write-Warning: C:\Users\TrevorSullivan\Documents\PowerShell\Modules\BurntToast\0.8.2\BurntToast.psm1:2430:27
Line |
2430 |              Write-Warning $Script:UnsupportedEvents
     |                            ~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'Message' because it is null.

Environment data


Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
OsName         : Microsoft Windows 10 Pro
OsVersion      : 10.0.19041
OsArchitecture : 64-bit


    Directory: C:\Users\TrevorSullivan\Documents\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     0.8.2                 BurntToast                          Desk      {Get-BTHistory, New-BTAction, New-BTAppId, New-BTAudio…}
@Windos
Copy link
Owner

Windos commented Sep 29, 2020

Cheers for opening this issue, @pcgeek86

Found it myself (finally) last night and have a patch ready which should be out in a day or two.

Problem was I added code into my .psm1 file to check for the ability to use events (and an error message if not)... but then I forgot to update the template used when building the release.


That will solve the error, but also when fixed you'll still get a warning when running that sample code.

This:

$Context = New-BTContextMenuItem -Content 'AWS Console' -ActivationType Protocol -Arguments https://console.aws.amazon.com

$Action = New-BTAction -ContextMenuItems $Context

Will give you a context menu item when you right click on the toast, which will work and open that webpage in your default browser.

image

This:

Submit-BTNotification -Content $Content -DismissedAction { chrome }

Will ignore the Dismissed action as the version of PowerShell was 7.0.3 (and we need 7.1 Preview 4 and above for these events). Under 7.0.3 (and Windows PowerShell), the expected outcome currently is:

WARNING: Toast events are only supported on PowerShell 7.1.0 and above. Your notification will still be displayed, but
the actions will be ignored.

Once fixed, and on 7.1, your toast would open the AWS page if activated through the right click context item (in default browser) or open a new instance of chrome if it is dismissed (user clicks the little "go to action center" icon or it times out).

Nothing would happen if the user clicks on the toast notification itself.

You can do protocols via clicking the toast by adding it to the New-BTContent function:

$Content = New-BTContent -Actions $Action -Visual $Visual -Launch 'https://google.com' -ActivationType Protocol

Random asside, that { chrome } may need to change to { start chrome }, the first doesn't work for me 🤔

@Windos
Copy link
Owner

Windos commented Sep 29, 2020

Also sorry for the word vomit. I know documentation is lacking atm, and these writeups tend to form the catalyst for that so I like to be... thorough!

@pcgeek86
Copy link
Author

I'm just glad it's documented somewhere, for future Google searches :)

@Windos Windos closed this as completed in ad26c49 Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants