Skip to content

Commit ffdee9b

Browse files
loneursidEric Langlois
andauthored
App Notification Samples: addressing nits from previous code-review (#219)
* Addressing nits from previous code-review * git prefers empty lines at the end of files Co-authored-by: Eric Langlois <[email protected]>
1 parent 547a928 commit ffdee9b

File tree

5 files changed

+38
-47
lines changed

5 files changed

+38
-47
lines changed

Samples/Notifications/App/CsUnpackagedAppNotifications/CsUnpackagedAppNotifications/MainPage.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public void NotificationReceived(Notification notification)
6363
if (DispatcherQueue.HasThreadAccess)
6464
{
6565
messages.Insert(0, text);
66-
6766
}
6867
else
6968
{

Samples/Notifications/App/CsUnpackagedAppNotifications/CsUnpackagedAppNotifications/Notifications/Common.cs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
#if false
5-
//#include "pch.h"
6-
//#include "Common.h"
7-
#endif
8-
94
class Common
105
{
116
const string scenarioTag = "scenarioId";
@@ -32,20 +27,20 @@ public static string ExtractParamFromArgs(string args, string paramName)
3227
return args.Substring(paramStart, paramEnd - paramStart);
3328
}
3429

35-
public static string MakeScenarioIdToken(int id)
36-
{
37-
return scenarioTag + "=" + id.ToString();
38-
}
30+
public static string MakeScenarioIdToken(int id)
31+
{
32+
return scenarioTag + "=" + id.ToString();
33+
}
3934

40-
public static int ExtractScenarioIdFromArgs(string args)
41-
{
42-
var scenarioId = ExtractParamFromArgs(args, scenarioTag);
35+
public static int ExtractScenarioIdFromArgs(string args)
36+
{
37+
var scenarioId = ExtractParamFromArgs(args, scenarioTag);
4338

44-
if (scenarioId == null)
45-
{
46-
return 0;
47-
}
39+
if (scenarioId == null)
40+
{
41+
return 0;
42+
}
4843

4944
return int.Parse(scenarioId);
50-
}
51-
}
45+
}
46+
}

Samples/Notifications/App/CsUnpackagedAppNotifications/CsUnpackagedAppNotifications/Notifications/NotificationManager.cs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
63

4+
using System;
5+
using System.Collections.Generic;
76
using Microsoft.Windows.AppNotifications;
8-
using Windows.Foundation;
9-
using Microsoft.UI.Xaml.Controls;
107

118
namespace CsUnpackagedAppNotifications.Notifications
129
{
@@ -63,21 +60,21 @@ public bool DispatchNotification(AppNotificationActivatedEventArgs notificationA
6360
{
6461
var scenarioId = Common.ExtractScenarioIdFromArgs(notificationActivatedEventArgs.Argument);
6562
if (scenarioId != 0)
66-
{
67-
try
68-
{
69-
c_notificationHandlers[scenarioId](notificationActivatedEventArgs);
70-
return true;
71-
}
72-
catch
73-
{
74-
return false; // Couldn't find a NotificationHandler for scenarioId.
75-
}
76-
}
77-
else
78-
{
79-
return false; // No scenario specified in the notification
80-
}
63+
{
64+
try
65+
{
66+
c_notificationHandlers[scenarioId](notificationActivatedEventArgs);
67+
return true;
68+
}
69+
catch
70+
{
71+
return false; // Couldn't find a NotificationHandler for scenarioId.
72+
}
73+
}
74+
else
75+
{
76+
return false; // No scenario specified in the notification
77+
}
8178
}
8279

8380
void OnNotificationInvoked(object sender, AppNotificationActivatedEventArgs notificationActivatedEventArgs)

Samples/Notifications/App/CsUnpackagedAppNotifications/CsUnpackagedAppNotifications/Notifications/ToastWithAvatar.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public static bool SendToast()
3333
var toast = new AppNotification(xmlPayload);
3434
AppNotificationManager.Default.Show(toast);
3535

36-
return toast.Id != 0; // return true (indicating success) if the toast was sent (if it has an Id)
37-
36+
return toast.Id != 0; // return true (indicating success) if the toast was sent (if it has an Id)
3837
}
3938

4039
public static void NotificationReceived(AppNotificationActivatedEventArgs notificationActivatedEventArgs)

Samples/Notifications/App/CsUnpackagedAppNotifications/CsUnpackagedAppNotifications/Notifications/ToastWithTextBox.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ public static bool SendToast()
4444

4545
public static void NotificationReceived(AppNotificationActivatedEventArgs notificationActivatedEventArgs)
4646
{
47-
// In a real-life scenario, this type of action would usually be processed in the background. Your App would process the payload in
48-
// the background (sending the payload back to your App Server) without ever showing the App's UI.
49-
// This is not something that can easily be demonstrated in a sample such as this one, as we need to show the UI to demonstrate how
50-
// the payload is routed internally
47+
// In a real-life scenario, this type of action would usually be processed in the background. Your App would process the payload in
48+
// the background (sending the payload back to your App Server) without ever showing the App's UI.
49+
// This is not something that can easily be demonstrated in a sample such as this one, as we need to show the UI to demonstrate how
50+
// the payload is routed internally
51+
5152
var input = notificationActivatedEventArgs.UserInput;
5253
var text = input[textboxReplyId];
5354

0 commit comments

Comments
 (0)