2016-08-03 44 views
0

ich Code unten bin mit dem Gerät (Windows Phone) in AWS SNS als Endpunkt in der AnwendungFehler: Die Sicherheitstoken in der Anforderung enthalten ist ungültig - Windows Phone Mit AWS SNS

CognitoAWSCredentials cognitoProvider = new CognitoAWSCredentials(UserId, 
         IdentitypoolID, 
         UnAuthRoleARN, 
         AuthRoleARN, 
         Region); 

      AmazonSimpleNotificationServiceClient sns = new AmazonSimpleNotificationServiceClient(cognitoProvider.GetCredentials().AccessKey.ToString(), 
       cognitoProvider.GetCredentials().SecretKey.ToString(), REgion); //provide credentials here 

      var channelOperation = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); 

      CreatePlatformEndpointRequest epReq = new CreatePlatformEndpointRequest(); 
      epReq.PlatformApplicationArn = ApplicationArn; 
      epReq.Token = channelOperation.Uri.ToString(); 

      CreatePlatformEndpointResponse epRes = await sns.CreatePlatformEndpointAsync(epReq); 

      CreateTopicRequest tpReq = new CreateTopicRequest(); 

      SubscribeResponse subsResp = await sns.SubscribeAsync(new SubscribeRequest() 
      { 
       TopicArn = TopicArn, 
       Protocol = "application", 
       Endpoint = epRes.EndpointArn 
      }); 

Während registrieren erstellen sie einen Endpunkt es einen Fehler die Sicherheits-Token in der Anforderung ist ungültig enthalten wirft, während unten Code ausführen

CreatePlatformEndpointResponse epRes = await sns.CreatePlatformEndpointAsync(epReq); 

Bitte helfen sie mir, dies zu erreichen. Vielen Dank im Voraus

Antwort

0

Verwenden Sie den folgenden Code, um ein Windows Phone-Gerät in der AWS SNS-Anwendung zu registrieren. Ich kann einen Endpunkt mit dem folgenden Code erstellen.

private async void Push() 
     { 
      CognitoAWSCredentials cognitoProvider = new CognitoAWSCredentials(UserId, 
        IdentitypoolID, 
        UnAuthRoleARN, 
        AuthRoleARN, 
        Region); 

      using (var sns = new AmazonSimpleNotificationServiceClient(credentials, RegionEndpoint.USEast1)) 
      { 
       var channelOperation = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); 

       CreatePlatformEndpointRequest epReq = new CreatePlatformEndpointRequest(); 
       epReq.PlatformApplicationArn = "PlatformApplicationARN"; 
       epReq.Token = channelOperation.Uri.ToString(); 

       CreatePlatformEndpointResponse epRes = await sns.CreatePlatformEndpointAsync(epReq); 

       CreateTopicRequest tpReq = new CreateTopicRequest(); 

       SubscribeResponse subsResp = await sns.SubscribeAsync(new SubscribeRequest() 
       { 
        TopicArn = "TopicARN", 
        Protocol = "application", 
        Endpoint = epRes.EndpointArn 
       }); 

       channelOperation.PushNotificationReceived += ChannelOperation_PushNotificationReceived; 
      } 
     }