WNS从AmazonSNS接收JSON数据

时间:2015-09-30 14:15:23

标签: c# json amazon-web-services amazon-sns

我想将此问题与我之前的问题联系起来 Can't receive any notification from AmazonSNS

在.appxmanifest上启用Toast后,该问题实际上正在运行。当我发布RAW消息类型而不是JSON时,我会收到通知,这是我实际需要的。代码在那里提供,但让我在这里重新发布

d("init AmazonSimpleNotificationServiceClient");
AmazonSimpleNotificationServiceClient sns = new AmazonSimpleNotificationServiceClient("secret", "secret", RegionEndpoint.EUWest1);

d("get notification channel uri");
string channel = string.Empty;
var channelOperation = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
channelOperation.PushNotificationReceived += ChannelOperation_PushNotificationReceived;

d("creating platform endpoint request");
CreatePlatformEndpointRequest epReq = new CreatePlatformEndpointRequest();
epReq.PlatformApplicationArn = "arn:aws:sns:eu-west-1:X413XXXX310X:app/WNS/Device";
d("token: " + channelOperation.Uri.ToString());
epReq.Token = channelOperation.Uri.ToString();

d("creat plateform endpoint");
CreatePlatformEndpointResponse epRes = await sns.CreatePlatformEndpointAsync(epReq);

d("endpoint arn: " + epRes.EndpointArn);

d("subscribe to topic");
SubscribeResponse subsResp = await sns.SubscribeAsync(new SubscribeRequest()
{
    TopicArn = "arn:aws:sns:eu-west-1:X413XXXX310X:Topic",
    Protocol = "application",
    Endpoint = epRes.EndpointArn
});

private void ChannelOperation_PushNotificationReceived(Windows.Networking.PushNotifications.PushNotificationChannel sender, Windows.Networking.PushNotifications.PushNotificationReceivedEventArgs args)
{
    Debug.WriteLine("receiving something");
}

发布RAW消息时会收到通知,但是当我以JSON消息类型发布时,我需要收到通知。我不确定为什么在使用该消息类型时我不会收到通知?我还缺少什么?

感谢

0 个答案:

没有答案