PendingUpdate を使用して、アプリの通知で複数ステップの対話を作成できます。 たとえば、後続の通知が前の通知からの応答に依存する一連の通知を作成できます。
アプリ通知の詳細については、「アプリ通知 の概要」を参照してください。
概要
保留中の更新をアクティベーション後の動作として使用する通知を実装するには、次のステップに従ってください。
- バックグラウンドのアクティブ化ボタンに、afterActivationBehavior を pendingUpdate に指定します。
- 通知を送信するときに タグ (および必要に応じて グループ) を割り当てます。
- ユーザーがボタンをクリックすると、バックグラウンド タスクがアクティブになり、通知は保留中の更新状態のままです。
- バックグラウンド タスクで、同じ タグ と グループ を使用して新しいコンテンツを含む新しい通知を送信し、保留中の通知を置き換えます。
保留中の更新の動作を設定します
注
AppNotificationButton は現在、 AfterActivationBehaviorをサポートしていません。 ボタンにを設定するには、afterActivationBehavior="pendingUpdate" コンストラクターで XML ペイロードを直接使用します。
背景のアクティブ化ボタンで、 afterActivationBehavior を pendingUpdate に設定します。 これは、 activationType="background"を持つボタンに対してのみ機能します。
using Microsoft.Windows.AppNotifications;
string xml = @"
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Would you like to order lunch today?</text>
</binding>
</visual>
<actions>
<action
content='Yes'
arguments='action=orderLunch'
activationType='background'
afterActivationBehavior='pendingUpdate'/>
<action
content='No'
arguments='action=cancelLunch'
activationType='background'/>
</actions>
</toast>";
var notification = new AppNotification(xml);
notification.Tag = "lunch";
AppNotificationManager.Default.Show(notification);
通知を新しいコンテンツに置き換える
ユーザーがボタンをクリックすると、バックグラウンド タスクがトリガーされ、同じ タグ と グループで新しい通知を送信して通知を置き換えます。 AppNotificationBuilder.MuteAudio を使用して、ユーザーが既に通知を操作しているため、ボタンのクリックに応じて置換時にオーディオをミュートします。
var notification = new AppNotificationBuilder()
.AddText("Ordering your lunch...")
.MuteAudio()
.BuildNotification();
notification.Tag = "lunch";
AppNotificationManager.Default.Show(notification);
こちらも参照ください
Windows developer