本文介绍了无法接收来自AmazonSNS任何通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我为什么不能从AmazonSNS收到任何通知。我缺少的东西在我的code?我使用AWSSDK为Windows Store应用了最新版本的方式。

下面是我的code为止。

  D(INIT AmazonSimpleNotificationServiceClient);
AmazonSimpleNotificationServiceClient SNS =新AmazonSimpleNotificationServiceClient(秘密,机密,RegionEndpoint.EUWest1);

D(得到通知通道URI);
字符串通道=的String.Empty;
VAR channelOperation =等待PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
channelOperation.PushNotificationReceived + = ChannelOperation_PushNotificationReceived;

D(创造平台端点请求);
CreatePlatformEndpointRequestËpreQ =新CreatePlatformEndpointRequest();
Ëpreq.PlatformApplicationArn =ARN:AWS:SNS:欧盟 - 西1:X413XXXX310X:应用程序/ WNS /设备;
D(令牌+ channelOperation.Uri.ToString());
Ëpreq.Token = channelOperation.Uri.ToString();

D(科瑞平板终端);
CreatePlatformEndpointResponseËpreS =等待sns.CreatePlatformEndpointAsync(E preQ);

D(端点ARN:+ E pres.EndpointArn);

D(订阅主题);
SubscribeResponse subsResp =等待sns.SubscribeAsync(新SubscribeRequest()
{
    TopicArn =ARN:AWS:SNS:欧盟 - 西1:X413XXXX310X:主题
    协议=应用程序,
    端点= E pres.EndpointArn
});

私人无效ChannelOperation_PushNotificationReceived(Windows.Networking.PushNotifications.PushNotificationChannel发件人,Windows.Networking.PushNotifications.PushNotificationReceivedEventArgs参数)
{
    的Debug.WriteLine(收到的东西);
}
 

解决方案

这实际上是对.appxmanifest使面包后工作

我得到通知,每次我发布从亚马逊SNS控制台RAW消息。我没有收到一个JSON,虽然这是我真正需要的。

I am not sure why I can't receive any notification from AmazonSNS. Am I missing something in my code? I am using the latest version of AWSSDK for Windows Store App by the way.

Here's my code so far.

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");
}
解决方案

this is actually working after enabling Toast on .appxmanifest

I get notified everytime I publish a RAW message from Amazon SNS console. I am not receiving a JSON though which I actually need.

这篇关于无法接收来自AmazonSNS任何通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 02:09