mercredi 30 septembre 2015

WNS receive JSON data from AmazonSNS

I want to link this question to my previous question Can't receive any notification from AmazonSNS

that question is actually working now after enabling Toast on .appxmanifest. I get notified when I publish a RAW message type but not JSON which is I actually need. The code is provided there but let me repost it here

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");
}

I get notified when a publish a RAW message but I need to get notified when I publish in JSON message type. I am not sure why I don't get notified when I use that message type? What else I am missing there?

thanks




Aucun commentaire:

Enregistrer un commentaire