Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
0ca6d3d
Original skeleton
Aug 4, 2021
78cfc8c
Corrected mismatches against PowerNotifications change
Aug 4, 2021
66f9073
Correcting few nits
Aug 4, 2021
065be70
Added constants usage, std::call_once and improved abstraction
Aug 5, 2021
a2b978e
Added StartupTask exe
Aug 5, 2021
9692554
Fixed some bugs
Aug 5, 2021
31b33c2
Mostly renaming and cleaning
Aug 7, 2021
1bdae4a
Merge branch 'main' into WNP_LRP
Aug 10, 2021
1856325
Removed timer externals and let winmain to own Platform lifetime
Aug 10, 2021
8ed2305
Correction -> factory should own the platform
Aug 10, 2021
5f6d8a6
Addressed lifetime crashes and other issues
Aug 12, 2021
040d069
Merge branch 'main' into WNP_LRP
Aug 12, 2021
1b11db4
Improved timer/event management
Aug 12, 2021
793e412
Addressed feedback
Aug 13, 2021
f9ba159
Fixed compilation issues in other flavor+archs and added minor comments
Aug 16, 2021
32f2668
Merge branch 'main' into WNP_LRP
Aug 16, 2021
8387ffd
Added a unit test (more coming!)
Aug 17, 2021
9f143dd
Test enhancements
Aug 18, 2021
0789a5d
Addressed comments
Aug 20, 2021
c943bdb
Merge branch 'main' into WNP_LRP
Aug 20, 2021
30fddd3
Moved timer/event logic to a platform component
Aug 20, 2021
b0ce0a1
Install Frameworkudk for LRP (#1271)
sharath2727 Aug 21, 2021
71cbc05
Merge branch 'main' into WNP_LRP
Aug 26, 2021
996fe8a
Merge branch 'main' into WNP_LRP
Aug 31, 2021
b2265f2
Introducing unpackaged foreground activation for PushNotifications (#…
pmpurifoy Sep 1, 2021
309f885
Not everything should be renamed Runtime
Sep 1, 2021
a361073
Merge branch 'main' into WNP_LRP
Sep 1, 2021
8185b1e
Ensuring the LRP msix gets built after the framework (#1356)
loneursid Sep 1, 2021
df11ff3
Merge branch 'main' into WNP_LRP
loneursid Sep 1, 2021
cfe344a
Bringing build management settings for release/arm64 in line with deb…
Sep 1, 2021
47b4640
Merge branch 'WNP_LRP' of https://github.com/microsoft/WindowsAppSDK …
Sep 1, 2021
3a222ff
Fixing arm64 build
Sep 1, 2021
c9ef497
Addressed comments
danielayala94 Sep 2, 2021
55614f3
Using winrt constructs on NotificationsLongRunningPlatformImpl :)
danielayala94 Sep 2, 2021
a0856a8
Merge branch 'main' into WNP_LRP
loneursid Sep 2, 2021
5623484
Channel Request for unpackaged applications (#1290)
sharath2727 Sep 2, 2021
a9b3295
Notification delivery + Protocol Activation (#1358)
danielayala94 Sep 3, 2021
f27f780
Merge branch 'main' into WNP_LRP
Sep 3, 2021
f455aa7
Merge branch 'main' into WNP_LRP
loneursid Sep 3, 2021
6ea2a56
Unpackaged notification unit tests (#1340)
loneursid Sep 3, 2021
7dfb673
Ensure errors get logged with telemetry
Sep 3, 2021
0e1661e
Workaround UDK include issue (#1364)
loneursid Sep 3, 2021
78cb42f
Some nits
pmpurifoy Sep 3, 2021
8496413
Addressed comments
danielayala94 Sep 3, 2021
3cab425
Fixed mistake - Removed comments
danielayala94 Sep 3, 2021
80469a4
Add LRP binaries to CopyFilestoStagingDir
pmpurifoy Sep 3, 2021
3a352a3
Merge branch 'WNP_LRP' of https://github.com/microsoft/WindowsAppSDK …
pmpurifoy Sep 3, 2021
b7b98b9
Addressed comments
danielayala94 Sep 3, 2021
ef8dfe2
Merge branch 'main' into WNP_LRP
danielayala94 Sep 4, 2021
5906c85
Merge branch 'main' into WNP_LRP
pmpurifoy Sep 7, 2021
f9f0abe
Merge main to LRP
pmpurifoy Sep 7, 2021
29b26b3
Merge branch 'main' into WNP_LRP
Sep 9, 2021
03aef23
Merge branch 'main' into WNP_LRP
Sep 10, 2021
fe5e582
Merge branch 'main' into WNP_LRP
Sep 13, 2021
6fd8605
Merge branch 'main' into WNP_LRP
Sep 14, 2021
256155e
Telemetry Update for Unpackaged Apps (#1385)
loneursid Sep 14, 2021
b40f14e
Merge branch 'main' into WNP_LRP
Sep 15, 2021
0336f90
Update to latest UDK and undo UDK hack (#1420)
loneursid Sep 15, 2021
401b47c
Fixing WNP_LRP tests (#1401)
pmpurifoy Sep 15, 2021
c482c4d
Merge branch 'main' into WNP_LRP
Sep 16, 2021
3b83c18
Merge branch 'main' into WNP_LRP
Sep 17, 2021
b25c2f8
Protocol Activation bug fixes (#1406)
danielayala94 Sep 18, 2021
f3b33df
Merge branch 'main' into WNP_LRP
Sep 19, 2021
d170ce3
Use remoteId as const value (#1435)
sharath2727 Sep 20, 2021
f53a1f0
Merge branch 'main' into WNP_LRP
Sep 21, 2021
ef733a6
Merge branch 'main' into WNP_LRP
Sep 21, 2021
41535f7
Merge branch 'main' into WNP_LRP
Sep 22, 2021
fbfcf49
Upgrade LRP to latest UDK (#1459)
loneursid Sep 22, 2021
f4be01c
Merge branch 'main' into WNP_LRP
Sep 23, 2021
66c645c
Merge branch 'main' into WNP_LRP
Sep 24, 2021
14a7f48
Merge branch 'main' into WNP_LRP
Sep 27, 2021
8e4da8e
Merge branch 'main' into WNP_LRP
Sep 28, 2021
1f9f936
Merge branch 'main' into WNP_LRP
Sep 29, 2021
2a7fae8
fix bad merge
Sep 29, 2021
a732c1d
Update CopyFilesToStagingDir.ps1
pmpurifoy Sep 29, 2021
2bf8f9f
Merge branch 'main' into WNP_LRP
Sep 30, 2021
e0f1df9
Remove PushNotifications from outer layer of JSON
pmpurifoy Sep 30, 2021
493a468
Adding source link to projects not in main yet (#1515)
loneursid Oct 1, 2021
17c18e5
Merge branch 'main' into WNP_LRP
Oct 1, 2021
a628d27
Merge branch 'main' into WNP_LRP
Oct 4, 2021
2acab7c
Support foregroundtask registration for packaged applications (#1521)
loneursid Oct 5, 2021
57ad725
Merge branch 'main' into WNP_LRP
Oct 5, 2021
a37ab1c
Merge branch 'main' into WNP_LRP
Oct 6, 2021
5d4dd66
Fix for regression in protocol activation in AppLifecycle (#1558)
loneursid Oct 8, 2021
3ff0db0
Merge branch 'main' into WNP_LRP
Oct 8, 2021
364bb41
LRP E2E Scenario fixes (#1543)
pmpurifoy Oct 8, 2021
94e1e75
Merge branch 'main' into WNP_LRP
Oct 9, 2021
598490e
Merge branch 'main' into WNP_LRP
Oct 13, 2021
da6fe4d
Updating LRP to use latest FrameworkUDK (#1587)
loneursid Oct 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions WindowsAppRuntime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PushNotifications", "PushNotifications", "{A1B25DCF-6A54-414D-8E24-F4D24EE9299D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PushNotificationsLongRunningTask.Msix", "test\PushNotifications\PushNotificationsLongRunningTask.Msix\PushNotificationsLongRunningTask.Msix.vcxproj", "{C422B090-F501-4204-8068-1084B0799405}"
ProjectSection(ProjectDependencies) = postProject
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE} = {9C1A6C58-52D6-4514-9120-5C339C5DF4BE}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PushNotificationsLongRunningTask.ProxyStub", "dev\PushNotifications\PushNotificationsLongRunningTask.ProxyStub\PushNotificationsLongRunningTask.ProxyStub.vcxproj", "{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PushNotificationsLongRunningTask.StartupTask", "dev\PushNotifications\PushNotificationsLongRunningTask.StartupTask\PushNotificationsLongRunningTask.StartupTask.vcxproj", "{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PowerNotifications", "PowerNotifications", "{E9117D76-63AC-4289-A628-AB39EF6E5D19}"
EndProject
Expand Down Expand Up @@ -244,6 +251,7 @@ Global
dev\EnvironmentManager\API\Microsoft.Process.Environment.vcxitems*{2f3fad1b-d3df-4866-a3a3-c2c777d55638}*SharedItemsImports = 9
dev\UndockedRegFreeWinRT\UndockedRegFreeWinRT.vcxitems*{56371ca6-144b-4989-a4e9-391ad4fa7651}*SharedItemsImports = 9
test\inc\inc.vcxitems*{56a1d696-feda-4333-bf37-772ebececb10}*SharedItemsImports = 4
test\inc\inc.vcxitems*{5b2d17fe-c371-417f-860c-3d32397c2404}*SharedItemsImports = 4
test\inc\inc.vcxitems*{7c502995-59c3-483b-86ba-815985353633}*SharedItemsImports = 4
test\inc\inc.vcxitems*{8e52d7ea-a200-4a6b-ba74-8efb49468caf}*SharedItemsImports = 4
test\inc\inc.vcxitems*{b567fe2e-3a03-48d0-b2b5-760cdec35891}*SharedItemsImports = 9
Expand Down Expand Up @@ -641,8 +649,8 @@ Global
{0A5FEE93-48B7-40EC-BB9A-B27D11060DA9}.Release|x86.ActiveCfg = Release|Win32
{0A5FEE93-48B7-40EC-BB9A-B27D11060DA9}.Release|x86.Build.0 = Release|Win32
{1307DD1B-BBE8-4CD0-B1A0-0DB6D61EEAA0}.Debug|Any CPU.ActiveCfg = Debug|Win32
{1307DD1B-BBE8-4CD0-B1A0-0DB6D61EEAA0}.Debug|ARM64.ActiveCfg = Debug|Win32
{1307DD1B-BBE8-4CD0-B1A0-0DB6D61EEAA0}.Debug|ARM64.Build.0 = Debug|Win32
{1307DD1B-BBE8-4CD0-B1A0-0DB6D61EEAA0}.Debug|ARM64.ActiveCfg = Debug|ARM64
{1307DD1B-BBE8-4CD0-B1A0-0DB6D61EEAA0}.Debug|ARM64.Build.0 = Debug|ARM64
{1307DD1B-BBE8-4CD0-B1A0-0DB6D61EEAA0}.Debug|x64.ActiveCfg = Debug|x64
{1307DD1B-BBE8-4CD0-B1A0-0DB6D61EEAA0}.Debug|x64.Build.0 = Debug|x64
{1307DD1B-BBE8-4CD0-B1A0-0DB6D61EEAA0}.Debug|x86.ActiveCfg = Debug|Win32
Expand All @@ -666,6 +674,34 @@ Global
{C422B090-F501-4204-8068-1084B0799405}.Release|x64.Build.0 = Release|x64
{C422B090-F501-4204-8068-1084B0799405}.Release|x86.ActiveCfg = Release|Win32
{C422B090-F501-4204-8068-1084B0799405}.Release|x86.Build.0 = Release|Win32
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Debug|Any CPU.ActiveCfg = Debug|Win32
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Debug|ARM64.ActiveCfg = Debug|ARM64
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Debug|ARM64.Build.0 = Debug|ARM64
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Debug|x64.ActiveCfg = Debug|x64
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Debug|x64.Build.0 = Debug|x64
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Debug|x86.ActiveCfg = Debug|Win32
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Debug|x86.Build.0 = Debug|Win32
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Release|Any CPU.ActiveCfg = Release|Win32
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Release|ARM64.ActiveCfg = Release|ARM64
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Release|ARM64.Build.0 = Release|ARM64
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Release|x64.ActiveCfg = Release|x64
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Release|x64.Build.0 = Release|x64
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Release|x86.ActiveCfg = Release|Win32
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0}.Release|x86.Build.0 = Release|Win32
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Debug|Any CPU.ActiveCfg = Debug|Win32
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Debug|ARM64.ActiveCfg = Debug|ARM64
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Debug|ARM64.Build.0 = Debug|ARM64
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Debug|x64.ActiveCfg = Debug|x64
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Debug|x64.Build.0 = Debug|x64
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Debug|x86.ActiveCfg = Debug|Win32
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Debug|x86.Build.0 = Debug|Win32
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Release|Any CPU.ActiveCfg = Release|Win32
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Release|ARM64.ActiveCfg = Release|ARM64
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Release|ARM64.Build.0 = Release|ARM64
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Release|x64.ActiveCfg = Release|x64
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Release|x64.Build.0 = Release|x64
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Release|x86.ActiveCfg = Release|Win32
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42}.Release|x86.Build.0 = Release|Win32
{CBD95746-61CE-4F31-B6CC-C5ABF1766180}.Debug|Any CPU.ActiveCfg = Debug|Win32
{CBD95746-61CE-4F31-B6CC-C5ABF1766180}.Debug|ARM64.ActiveCfg = Debug|Win32
{CBD95746-61CE-4F31-B6CC-C5ABF1766180}.Debug|x64.ActiveCfg = Debug|x64
Expand Down Expand Up @@ -936,6 +972,8 @@ Global
{1307DD1B-BBE8-4CD0-B1A0-0DB6D61EEAA0} = {91D03B95-1B0C-4BEB-8441-30DA7D615538}
{A1B25DCF-6A54-414D-8E24-F4D24EE9299D} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{C422B090-F501-4204-8068-1084B0799405} = {A1B25DCF-6A54-414D-8E24-F4D24EE9299D}
{BF3FCED0-CADB-490A-93A7-4D90E1F45AB0} = {91D03B95-1B0C-4BEB-8441-30DA7D615538}
{1DEBBFF6-EE6E-4944-9DE2-35B7A686AF42} = {91D03B95-1B0C-4BEB-8441-30DA7D615538}
{E9117D76-63AC-4289-A628-AB39EF6E5D19} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
{B75C1B22-553C-40E4-B38E-6AB4D01FDB9D} = {E9117D76-63AC-4289-A628-AB39EF6E5D19}
{CBD95746-61CE-4F31-B6CC-C5ABF1766180} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
Expand Down
18 changes: 16 additions & 2 deletions build/CopyFilesToStagingDir.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function PublishFile {
}

PublishFile $OverrideDir\DynamicDependency-Override.json $FullPublishDir\
PublishFile $OverrideDir\PushNotifications-Override.json $FullPublishDir\

PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.WindowsAppRuntime.dll $FullPublishDir\Microsoft.WindowsAppRuntime\
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.WindowsAppRuntime.lib $FullPublishDir\Microsoft.WindowsAppRuntime\
Expand Down Expand Up @@ -87,6 +88,9 @@ PublishFile $FullBuildOutput\Microsoft.Windows.System.Power.Projection\Microsoft
# Dynamic Dependency build overrides
PublishFile $OverrideDir\DynamicDependency-Override.json $NugetDir\runtimes\win10-$Platform\native
#
# Push Notifications build overrides
PublishFile $OverrideDir\PushNotifications-Override.json $NugetDir\runtimes\win10-$Platform\native
#
# Includes (*.h)
PublishFile $FullBuildOutput\WindowsAppRuntime_BootstrapDLL\MddBootstrap.h $NugetDir\include
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\MsixDynamicDependency.h $NugetDir\include
Expand All @@ -104,11 +108,17 @@ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.WindowsAppRuntime.p
# MSIX Main package
PublishFile $FullBuildOutput\DynamicDependency.DataStore\DynamicDependency.DataStore.exe $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\DynamicDependency.DataStore\DynamicDependency.DataStore.pdb $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\PushNotificationsLongRunningTask\PushNotificationsLongRunningTask.exe $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\PushNotificationsLongRunningTask\PushNotificationsLongRunningTask.pdb $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\DynamicDependency.DataStore.ProxyStub\DynamicDependency.DataStore.ProxyStub.dll $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\DynamicDependency.DataStore.ProxyStub\DynamicDependency.DataStore.ProxyStub.pdb $NugetDir\runtimes\win10-$Platform\native
#
# PushNotifications LRP
PublishFile $FullBuildOutput\PushNotificationsLongRunningTask\PushNotificationsLongRunningTask.exe $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\PushNotificationsLongRunningTask\PushNotificationsLongRunningTask.pdb $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\PushNotificationsLongRunningTask.StartupTask\PushNotificationsLongRunningTask.StartupTask.exe $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\PushNotificationsLongRunningTask.StartupTask\PushNotificationsLongRunningTask.StartupTask.pdb $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\PushNotificationsLongRunningTask.ProxyStub\PushNotificationsLongRunningTask.ProxyStub.dll $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\PushNotificationsLongRunningTask.ProxyStub\PushNotificationsLongRunningTask.ProxyStub.pdb $NugetDir\runtimes\win10-$Platform\native
#
# MSIX DDLM package
PublishFile $FullBuildOutput\DynamicDependencyLifetimeManager\DynamicDependencyLifetimeManager.exe $NugetDir\runtimes\win10-$Platform\native
PublishFile $FullBuildOutput\DynamicDependencyLifetimeManager\DynamicDependencyLifetimeManager.pdb $NugetDir\runtimes\win10-$Platform\native
Expand All @@ -129,3 +139,7 @@ PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.Windows.Application
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.Windows.ApplicationModel.WindowsAppRuntime.winmd $NugetDir\lib\uap10.0
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.Windows.System.winmd $NugetDir\lib\uap10.0
PublishFile $FullBuildOutput\WindowsAppRuntime_DLL\Microsoft.Windows.System.Power.winmd $NugetDir\lib\uap10.0
#
# Build overrides
PublishFile $OverrideDir\DynamicDependency-Override.json $NugetDir\runtimes\win10-$Platform\native
PublishFile $OverrideDir\PushNotifications-Override.json $NugetDir\runtimes\win10-$Platform\native
2 changes: 1 addition & 1 deletion dev/AppLifecycle/ActivationRegistrationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace winrt::Microsoft::Windows::AppLifecycle::implementation

// Example: C:\some\path\App.exe "----ms-protocol:myscheme:some=data&some=other"
return wil::str_printf<std::wstring>(L"%s \"%s%s%s%s\"", exePath.c_str(), c_argumentPrefix,
c_protocolArgumentString, c_argumentSuffix, argumentData.c_str());
c_msProtocolArgumentString, c_argumentSuffix, argumentData.c_str());
}

void ActivationRegistrationManager::RegisterForFileTypeActivation(
Expand Down
3 changes: 2 additions & 1 deletion dev/AppLifecycle/ActivationRegistrationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace winrt::Microsoft::Windows::AppLifecycle::implementation
// Registration constant values.
static PCWSTR c_argumentPrefix{ L"----" };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use const or constexpr instead of static. statis results in unique copies of the variables in every translation unit that includes it.

static PCWSTR c_argumentSuffix{ L":" };
static PCWSTR c_protocolArgumentString{ L"ms-protocol" };
static PCWSTR c_msProtocolArgumentString{ L"ms-protocol" };
static PCWSTR c_pushProtocolArgumentString{ L"WindowsAppRuntimePushServer" };
static PCWSTR c_runKeyPath{ LR"(Software\Microsoft\Windows\CurrentVersion\Run\)" };

struct ActivationRegistrationManager
Expand Down
54 changes: 42 additions & 12 deletions dev/AppLifecycle/AppInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ using namespace winrt::Windows::ApplicationModel::Activation;

namespace winrt::Microsoft::Windows::AppLifecycle::implementation
{
static PCWSTR c_pushPayloadAttribute{ L"-Payload:" };

INIT_ONCE AppInstance::s_initOnce{};
winrt::com_ptr<AppInstance> AppInstance::s_current;

std::tuple<std::wstring, std::wstring> ParseCommandLine(const std::wstring& commandLine)
std::tuple<std::wstring, std::wstring> GetActivationArguments(PWSTR argv[], int argc, PCWSTR activationKind)
{
int argc{};
wil::unique_hlocal_ptr<PWSTR[]> argv{ CommandLineToArgvW(commandLine.c_str(), &argc) };

// Search for ----ms-protocol:
for (int index = 0; index < argc; index++)
{
std::wstring_view fullArgument = argv[index];
auto protocolQualifier = wil::str_printf<std::wstring>(L"%s%s%s", c_argumentPrefix, c_protocolArgumentString, c_argumentSuffix);
auto protocolQualifier = wil::str_printf<std::wstring>(L"%s%s%s", c_argumentPrefix, activationKind, c_argumentSuffix);

auto argStart = fullArgument.find(protocolQualifier);
if (argStart == std::wstring::npos)
Expand All @@ -55,6 +53,25 @@ namespace winrt::Microsoft::Windows::AppLifecycle::implementation
return { argument.substr(0, argsDelim), argument.substr(argsDelim + 1) };
}

return { L"", L""};
}

std::tuple<std::wstring, std::wstring> ParseCommandLine(const std::wstring& commandLine)
{
int argc{};

wil::unique_hlocal_ptr<PWSTR[]> argv{ CommandLineToArgvW(commandLine.c_str(), &argc) };

PCWSTR activationKinds[] = { c_msProtocolArgumentString, c_pushProtocolArgumentString };
for (auto activationKind : activationKinds)
{
auto [ kind, data ] = GetActivationArguments(argv.get(), argc, activationKind);
if (kind != L"")
{
return { kind, data };
}
}

return { L"", L"" };
}

Expand Down Expand Up @@ -341,17 +358,30 @@ namespace winrt::Microsoft::Windows::AppLifecycle::implementation
// protocol, except the catch-all LaunchActivatedEventArgs case.
if (!contractArgument.empty())
{
if (contractData.empty())
if (contractArgument == c_pushProtocolArgumentString)
{
Comment thread
danielayala94 marked this conversation as resolved.
// If the contractData is empty, handle any aliased encoded launches.
if (CompareStringOrdinal(contractArgument.data(), static_cast<int>(contractArgument.size()), L"WindowsAppRuntimePushServer", -1, TRUE) == CSTR_EQUAL)
// Generate a basic encoded launch Uri for all Push activations.
std::wstring tempContractData = GenerateEncodedLaunchUri(L"App", c_pushContractId);
contractArgument = c_msProtocolArgumentString;

// A non-empty contractData means we have a payload.
// This contains a background notification. It is specific to unpackaged apps.
// It requires further processing to build PushNotificationReceivedEventArgs.
// For packaged apps we don't need extra processing. A basic encoded launch Uri is sufficient.
auto index = contractData.find(c_pushPayloadAttribute);

if (!contractData.empty() && index == 0)
{
contractData = GenerateEncodedLaunchUri(L"App", c_pushContractId);
contractArgument = c_protocolArgumentString;
tempContractData += L"&payload=";
// 9 -> the size of &payload= as quotes in the contrat data will
// have been tripped in the call to ParseCommandLine.
tempContractData += contractData.substr(9, contractData.size() - 9);
}

contractData = tempContractData;
}

if (CompareStringOrdinal(contractArgument.c_str(), static_cast<int>(contractArgument.size()), c_protocolArgumentString, -1, TRUE) == CSTR_EQUAL)
if (CompareStringOrdinal(contractArgument.c_str(), static_cast<int>(contractArgument.size()), c_msProtocolArgumentString, -1, TRUE) == CSTR_EQUAL)
{
kind = ExtendedActivationKind::Protocol;
auto args = make<ProtocolActivatedEventArgs>(contractData.c_str());
Expand Down
16 changes: 15 additions & 1 deletion dev/PushNotifications/GetRawNotificationEventArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,22 @@ constexpr PCWSTR c_pushContractId = L"Windows.Push";

namespace winrt::Microsoft::Windows::PushNotifications
{
static winrt::Windows::Foundation::IInspectable Deserialize(winrt::Windows::Foundation::Uri const&)
static winrt::Windows::Foundation::IInspectable Deserialize(winrt::Windows::Foundation::Uri const& uri)
{
// Verify if the uri contains a background notification payload.
// Otherwise, we expect to process the notification in a background task.
for (auto const& pair : uri.QueryParsed())
{
if (pair.Name() == L"payload")
{
// Convert escaped components to its normal content
// from the conversion done in the LRP (see NotificationListener.cpp)
std::wstring payloadAsEscapedWstring{ pair.Value() };
std::wstring payloadAsWstring{ winrt::Windows::Foundation::Uri::UnescapeComponent(payloadAsEscapedWstring) };
return winrt::make<winrt::Microsoft::Windows::PushNotifications::implementation::PushNotificationReceivedEventArgs>(payloadAsWstring);
}
}

const DWORD receiveArgsTimeoutInMSec{ 2000 };
THROW_HR_IF(HRESULT_FROM_WIN32(ERROR_TIMEOUT), !GetWaitHandleForArgs().wait(receiveArgsTimeoutInMSec));

Expand Down
Loading