望ましい動作は、アプリで生の通知をインターセプトすることです (バックグラウンド タスクやユーザーが貴重なバックグラウンド タスク スポットの 1 つを放棄する必要はありません)。http://msdn.microsoft.com/en-us/library/windows/apps/xaml/JJ709907(v=win.10).aspxのサンプル コードに従って、生の通知をインターセプトするイベント ハンドラーを作成しました。私が作成した 1 つのアプリでは、Azure Mobile Services を使用して WNS 経由で通知を送信し、イベント ハンドラーがトリガーされ、うまく機能します。
しかし、2 つ目のアプリでは機能しません。通知は問題ないようです。つまり、Web サービスが WNS を取得してトースト通知を送信すると、トースト通知が表示されます。また、未加工の通知をデバッグ/トレースすることもでき、それらも問題なく作成されているように見えます。不足している設定はありますか?
Fiddler 経由で要求と結果が表示されますが、MVC 4.0 Web API プロジェクトをローカルで実行しているからかもしれません。リクエストは次のようになります。
{Channel URI: https://bn1.notify.windows.com/?token=AgYAAACuGgtx...
TTL: -
Cache: no
Request for status: no
Tag:
Priority: Normal
Token retry count: 0
really
}
次に、これを追跡できます (すべて、WAT サンプルの一部である WNSRecipe/NotificationsExtensions コードを使用して実行されます)。私は得る:
{Sent WNS notification: Received
Channel URI: https://bn1.notify.windows.com/?token=AgYAAACuGgtx...
Notification status: Received
Status code: OK
Device connection status: NotApplicable
Error description:
Debug Trace: BN1WNS2011828
MessageId: 3FA318CE5C48E9CF
Timestamp: 3/8/2013 9:23:18 PM -07:00
- REQUEST ------------------------------------------------------------------
X-WNS-Type : wns/raw
Content-Type : application/octet-stream
Authorization : Bearer EgAaAQMAAAAEgAAACoAAx1d3DqT9jZxJdOFIUJ9...
Host : bn1.notify.windows.com
Content-Length : 6
really
- RESPONSE -----------------------------------------------------------------
X-WNS-NOTIFICATIONSTATUS : received
X-WNS-MSG-ID : 3FA318CE5C48E9CF
X-WNS-DEBUG-TRACE : BN1WNS2011828
Content-Length : 0
Date : Sat, 09 Mar 2013 04:23:11 GMT
}
そして結果:
{Channel URI: https://bn1.notify.windows.com/?token=AgYAAACuGgtx...
Notification status: Received
Status code: OK
Device connection status: NotApplicable
Error description:
Debug Trace: BN1WNS2011828
MessageId: 3FA318CE5C48E9CF
Timestamp: 3/8/2013 9:23:18 PM -07:00
}
したがって、通知が送信されていると思います。
更新: 戻って設定を再確認し、リクエストを POST するためのテスト ボタンをアプリに追加しました。(だから私はアプリがアクティブであることを知っています、間違いありません)。通知リクエストに追加RequestForStatus = true
したところ、「デバイスの接続ステータス: 接続済み」と、イベント ビューアーに新しいログ エントリ セットが返されました。