Skip to content

Commit a766d3c

Browse files
Merge pull request #5357 from MicrosoftDocs/main638808583768010834sync_temp
For protected branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 372c762 + 5b1c2df commit a766d3c

File tree

2 files changed

+47
-41
lines changed

2 files changed

+47
-41
lines changed

hub/apps/desktop/modernize/grant-identity-to-nonpackaged-apps.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ Note the below important details about this code:
149149
* Set `externalLocation` to the absolute path of your application's installation directory (without any executable names)
150150
* Set `packagePath` to the absolute path of the identity package produced in the previous step (with the file name)
151151

152-
For a complete example including unregistering the package on uninstall, see [`StartUp.cs`](https://github.com/microsoft/AppModelSamples/blob/0c019d835d194dfc65ee0c0663086582d48165a9/Samples/SparsePackages/PhotoStoreDemo/StartUp.cs#L146-L220).
152+
For production-ready code in C# and C++, see [Sample apps](#sample-apps) below. The samples also demonstrate how to unregister the identity package on uninstall.
153153

154-
## Sample app
154+
## Sample apps
155155

156-
See the [SparsePackages](https://github.com/microsoft/AppModelSamples/tree/master/Samples/SparsePackages) sample for a fully functional sample app that demonstrates how to grant package identity to a desktop app by registering an identity package.
156+
See the [PackageWithExternalLocation](https://aka.ms/sparsepkgsample) samples for fully functional C# and C++ apps that demonstrate how to register an identity package.

hub/apps/windows-app-sdk/migrate-to-windows-app-sdk/guides/toast-notifications.md

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private void LaunchAndBringToForegroundIfNeeded()
189189
m_window.Activate();
190190

191191
// Additionally we show using our helper, since if activated via a app notification, it doesn't
192-
// activate the window correctly
192+
// activate the window correctly.
193193
WindowHelper.ShowWindow(m_window);
194194
}
195195
else
@@ -205,37 +205,43 @@ private void NotificationManager_NotificationInvoked(AppNotificationManager send
205205

206206
private void HandleNotification(AppNotificationActivatedEventArgs args)
207207
{
208-
// Use the dispatcher from the window if present, otherwise the app dispatcher
208+
// Use the dispatcher from the window if present, otherwise the app dispatcher.
209209
var dispatcherQueue = m_window?.DispatcherQueue ?? DispatcherQueue.GetForCurrentThread();
210210

211211

212212
dispatcherQueue.TryEnqueue(async delegate
213213
{
214-
215-
switch (args.Arguments["action"])
214+
if (args.Argument.Contains("action"))
216215
{
217-
// Send a background message
218-
case "sendMessage":
219-
string message = args.UserInput["textBox"].ToString();
220-
// TODO: Send it
221-
222-
// If the UI app isn't open
223-
if (m_window == null)
224-
{
225-
// Close since we're done
226-
Process.GetCurrentProcess().Kill();
227-
}
228-
229-
break;
230-
231-
// View a message
232-
case "viewMessage":
233-
234-
// Launch/bring window to foreground
235-
LaunchAndBringToForegroundIfNeeded();
236-
237-
// TODO: Open the message
238-
break;
216+
switch (args.Arguments["action"])
217+
{
218+
// Send a background message.
219+
case "sendMessage":
220+
string message = args.UserInput["textBox"].ToString();
221+
// TODO: Send it.
222+
223+
// If the UI app isn't open.
224+
if (m_window == null)
225+
{
226+
// Close since we're done.
227+
Process.GetCurrentProcess().Kill();
228+
}
229+
230+
break;
231+
232+
// View a message.
233+
case "viewMessage":
234+
235+
// Launch/bring window to foreground.
236+
LaunchAndBringToForegroundIfNeeded();
237+
238+
// TODO: Open the message.
239+
break;
240+
}
241+
}
242+
else
243+
{
244+
Debug.Print("Notification args is null");
239245
}
240246
});
241247
}
@@ -281,14 +287,14 @@ public static DispatcherQueue DispatcherQueue { get; private set; }
281287

282288
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
283289
{
284-
// Get the app-level dispatcher
290+
// Get the app-level dispatcher.
285291
DispatcherQueue = global::Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
286292

287-
// Register for toast activation. Requires Microsoft.Toolkit.Uwp.Notifications NuGet package version 7.0 or greater
293+
// Register for toast activation. Requires Microsoft.Toolkit.Uwp.Notifications NuGet package version 7.0 or greater.
288294
ToastNotificationManagerCompat.OnActivated += ToastNotificationManagerCompat_OnActivated;
289295

290296
// If we weren't launched by an app, launch our window like normal.
291-
// Otherwise if launched by a toast, our OnActivated callback will be triggered
297+
// Otherwise if launched by a toast, our OnActivated callback will be triggered.
292298
if (!ToastNotificationManagerCompat.WasCurrentProcessToastActivated())
293299
{
294300
LaunchAndBringToForegroundIfNeeded();
@@ -303,7 +309,7 @@ private void LaunchAndBringToForegroundIfNeeded()
303309
m_window.Activate();
304310

305311
// Additionally we show using our helper, since if activated via a toast, it doesn't
306-
// activate the window correctly
312+
// activate the window correctly.
307313
WindowHelper.ShowWindow(m_window);
308314
}
309315
else
@@ -314,7 +320,7 @@ private void LaunchAndBringToForegroundIfNeeded()
314320

315321
private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e)
316322
{
317-
// Use the dispatcher from the window if present, otherwise the app dispatcher
323+
// Use the dispatcher from the window if present, otherwise the app dispatcher.
318324
var dispatcherQueue = m_window?.DispatcherQueue ?? App.DispatcherQueue;
319325

320326
dispatcherQueue.TryEnqueue(delegate
@@ -323,27 +329,27 @@ private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivat
323329

324330
switch (args["action"])
325331
{
326-
// Send a background message
332+
// Send a background message.
327333
case "sendMessage":
328334
string message = e.UserInput["textBox"].ToString();
329-
// TODO: Send it
335+
// TODO: Send it.
330336
331-
// If the UI app isn't open
337+
// If the UI app isn't open.
332338
if (m_window == null)
333339
{
334-
// Close since we're done
340+
// Close since we're done.
335341
Process.GetCurrentProcess().Kill();
336342
}
337343

338344
break;
339345

340-
// View a message
346+
// View a message.
341347
case "viewMessage":
342348

343-
// Launch/bring window to foreground
349+
// Launch/bring window to foreground.
344350
LaunchAndBringToForegroundIfNeeded();
345351

346-
// TODO: Open the message
352+
// TODO: Open the message.
347353
break;
348354
}
349355
});

0 commit comments

Comments
 (0)