예제 #1
0
        public void TestCreatePlatformApplication()
        {
            // of the array is one line of the file.
            string[] lines = System.IO.File.ReadAllLines(@"C:\keys.txt");
            string   accK  = lines[0];
            string   secK  = lines[1];

            NotificationManager nm = new NotificationManager(accK, secK, Amazon.RegionEndpoint.USEast1);

            nm.init();
            string topicArn1 = nm.createPlatformApplicationAndAttachToTopic("exampletoken", "username");
            string topicArn2 = nm.createPlatformApplicationAndAttachToTopic("exampletoken1", "username1");

            AmazonSimpleNotificationServiceClient snsClient = new AmazonSimpleNotificationServiceClient(accK, secK, Amazon.RegionEndpoint.USEast1);

            var topic = snsClient.FindTopic(nm.getTopicName("username"));

            Assert.AreEqual(topic.TopicArn, topicArn1);

            var topic1 = snsClient.FindTopic(nm.getTopicName("username1"));

            Assert.AreEqual(topic1.TopicArn, topicArn2);

            string topicArn3 = nm.createPlatformApplicationAndAttachToTopic("exampletoken2", "username");
            string topicArn4 = nm.createPlatformApplicationAndAttachToTopic("exampletoken3", "username1");

            Assert.AreEqual(topicArn1, topicArn3);
            Assert.AreEqual(topicArn2, topicArn4);

            try
            {
                topicArn1 = nm.createPlatformApplicationAndAttachToTopic("exampletoken", "username");
                Assert.Fail("Created a platform for same username and device token");
            }

            catch (Exception e)
            {
                Assert.IsTrue(e != null);
            }

            var appsResponse = snsClient.ListPlatformApplications();
            int i            = 0;

            foreach (var app in appsResponse.PlatformApplications)
            {
                var appAttrsRequest = new GetPlatformApplicationAttributesRequest
                {
                    PlatformApplicationArn = app.PlatformApplicationArn
                };

                i++;
                var appAttrsResponse = snsClient.GetPlatformApplicationAttributes(appAttrsRequest);
                System.Diagnostics.Trace.WriteLine(app.PlatformApplicationArn);
            }

            //Assert.AreEqual(2, i);
        }
예제 #2
0
        public static void SNSMobilePushAPIsListApplicationsEndpoints()
        {
            #region SNSMobilePushAPIsListApplicationsEndpoints
            var snsClient    = new AmazonSimpleNotificationServiceClient();
            var appsResponse = snsClient.ListPlatformApplications();

            foreach (var app in appsResponse.PlatformApplications)
            {
                Console.WriteLine();

                var appAttrsRequest = new GetPlatformApplicationAttributesRequest
                {
                    PlatformApplicationArn = app.PlatformApplicationArn
                };

                var appAttrsResponse =
                    snsClient.GetPlatformApplicationAttributes(appAttrsRequest);

                var endpointsByAppRequest =
                    new ListEndpointsByPlatformApplicationRequest
                {
                    PlatformApplicationArn = app.PlatformApplicationArn
                };

                var endpointsByAppResponse =
                    snsClient.ListEndpointsByPlatformApplication(
                        endpointsByAppRequest);

                Console.WriteLine("Application: " + app.PlatformApplicationArn);
                Console.WriteLine("  Properties: ");

                foreach (var attr in appAttrsResponse.Attributes)
                {
                    Console.WriteLine("    " + attr.Key + ": " + attr.Value);
                }

                Console.WriteLine("  Endpoints: ");

                foreach (var endpoint in endpointsByAppResponse.Endpoints)
                {
                    Console.WriteLine("     ARN: " + endpoint.EndpointArn);
                    Console.WriteLine("     Attributes: ");

                    foreach (var attr in endpoint.Attributes)
                    {
                        Console.WriteLine("       " + attr.Key + ": " + attr.Value);
                    }
                }
            }
            #endregion

            Console.ReadLine();
        }
예제 #3
0
 public Task <GetPlatformApplicationAttributesResponse> GetPlatformApplicationAttributesAsync(GetPlatformApplicationAttributesRequest request, CancellationToken cancellationToken = default(CancellationToken))
 {
     throw new System.NotImplementedException();
 }
예제 #4
0
 public GetPlatformApplicationAttributesResponse GetPlatformApplicationAttributes(GetPlatformApplicationAttributesRequest request)
 {
     throw new System.NotImplementedException();
 }
        /// <summary>
        /// Initiates the asynchronous execution of the GetPlatformApplicationAttributes operation.
        /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/>
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetPlatformApplicationAttributes operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task <GetPlatformApplicationAttributesResponse> GetPlatformApplicationAttributesAsync(GetPlatformApplicationAttributesRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new GetPlatformApplicationAttributesRequestMarshaller();
            var unmarshaller = GetPlatformApplicationAttributesResponseUnmarshaller.Instance;

            return(Invoke <IRequest, GetPlatformApplicationAttributesRequest, GetPlatformApplicationAttributesResponse>(request, marshaller, unmarshaller, signer, cancellationToken));
        }
        internal GetPlatformApplicationAttributesResponse GetPlatformApplicationAttributes(GetPlatformApplicationAttributesRequest request)
        {
            var task = GetPlatformApplicationAttributesAsync(request);

            try
            {
                return(task.Result);
            }
            catch (AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return(null);
            }
        }
예제 #7
0
 public void GetPlatformApplicationAttributesAsync(GetPlatformApplicationAttributesRequest request, AmazonServiceCallback <GetPlatformApplicationAttributesRequest, GetPlatformApplicationAttributesResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }
예제 #8
0
        internal GetPlatformApplicationAttributesResponse GetPlatformApplicationAttributes(GetPlatformApplicationAttributesRequest request)
        {
            var marshaller   = new GetPlatformApplicationAttributesRequestMarshaller();
            var unmarshaller = GetPlatformApplicationAttributesResponseUnmarshaller.Instance;

            return(Invoke <GetPlatformApplicationAttributesRequest, GetPlatformApplicationAttributesResponse>(request, marshaller, unmarshaller));
        }