Exemplo n.º 1
0
        public string createPlatformApplicationAndAttachToTopic(string deviceToken, string username)
        {
            if (deviceToken == null || username == null)
            {
                throw new ArgumentException("Passing null device token or username");
            }

            var topicRequest = new CreateTopicRequest
            {
                Name = username + "_myTopic"
            };

            var topicResponse = snsClient.CreateTopic(topicRequest);


            var createPlatformApplicationRequest = new CreatePlatformApplicationRequest
            {
                // Platform Credential is the SERVER API KEY FOR GCM
                Attributes = new Dictionary <string, string>()
                {
                    { "PlatformCredential", API_KEY }, { "EventEndpointCreated", topicResponse.TopicArn }
                },
                Name     = username + "_platform",
                Platform = "GCM"
            };

            var createPlatformResponse = snsClient.CreatePlatformApplication(createPlatformApplicationRequest);

            string platformApplicationArn = createPlatformResponse.PlatformApplicationArn;

            var request1 = new CreatePlatformEndpointRequest
            {
                CustomUserData         = "",
                PlatformApplicationArn = platformApplicationArn,
                Token = deviceToken
            };

            // Getting the endpoint result
            // It contains Endpoint ARN that needs to be subscripted to a topic
            var createPlatformEndpointResult = snsClient.CreatePlatformEndpoint(request1);


            try
            {
                snsClient.Subscribe(new SubscribeRequest
                {
                    Protocol = "application",
                    TopicArn = topicResponse.TopicArn,
                    Endpoint = createPlatformEndpointResult.EndpointArn
                });
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                return(null);
            }

            return(topicResponse.TopicArn);
        }
Exemplo n.º 2
0
        internal CreatePlatformApplicationResponse CreatePlatformApplication(CreatePlatformApplicationRequest request)
        {
            var marshaller   = new CreatePlatformApplicationRequestMarshaller();
            var unmarshaller = CreatePlatformApplicationResponseUnmarshaller.Instance;

            return(Invoke <CreatePlatformApplicationRequest, CreatePlatformApplicationResponse>(request, marshaller, unmarshaller));
        }
Exemplo n.º 3
0
        private CreatePlatformApplicationRequest CreatePlatformApplicaitonRequest(DeveloperOptions devOptions)
        {
            var request = new CreatePlatformApplicationRequest()
            {
                // TODO - need to determine where defaults are used, and then not create the constructor where value is null (to use default)
                Name       = devOptions.PlatformApplicationName,
                Attributes = devOptions.PlatformAttributes,
                Platform   = devOptions.MessagingPlatform
                             // These are required values.
            };

            return(request);
        }
        internal CreatePlatformApplicationResponse CreatePlatformApplication(CreatePlatformApplicationRequest request)
        {
            var task = CreatePlatformApplicationAsync(request);

            try
            {
                return(task.Result);
            }
            catch (AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return(null);
            }
        }
Exemplo n.º 5
0
        public static void SNSMobilePushAPIsCreatePlatformApplication()
        {
            #region SNSMobilePushAPIsCreatePlatformApplication
            var snsClient = new AmazonSimpleNotificationServiceClient();

            var request = new CreatePlatformApplicationRequest
            {
                Attributes = new Dictionary <string, string>()
                {
                    { "PlatformCredential", "AIzaSyDM1GHqKEdVg1pVFTXPReFT7UdGEXAMPLE" }
                },
                Name     = "TimeCardProcessingApplication",
                Platform = "GCM"
            };

            snsClient.CreatePlatformApplication(request);
            #endregion
        }
Exemplo n.º 6
0
        public string[] createPlatformApplication(string deviceToken, string username)
        {
            if (deviceToken == null || username == null)
            {
                throw new ArgumentException("Passing null device token or username");
            }

            var createPlatformApplicationRequest = new CreatePlatformApplicationRequest
            {
                // Platform Credential is the SERVER API KEY FOR GCM
                Attributes = new Dictionary <string, string>()
                {
                    { "PlatformCredential", API_KEY }
                },
                Name     = username + "_platform",
                Platform = "GCM"
            };

            var createPlatformResponse = snsClient.CreatePlatformApplication(createPlatformApplicationRequest);

            string platformApplicationArn = createPlatformResponse.PlatformApplicationArn;

            var request1 = new CreatePlatformEndpointRequest
            {
                CustomUserData         = "",
                PlatformApplicationArn = platformApplicationArn,
                Token = deviceToken
            };

            // Getting the endpoint result
            // It contains Endpoint ARN that needs to be subscripted to a topic
            var createPlatformEndpointResult = snsClient.CreatePlatformEndpoint(request1);


            string[] arr = new string[2] {
                "", ""
            };
            arr[1] = createPlatformEndpointResult.EndpointArn;
            arr[0] = platformApplicationArn;

            return(arr);
        }
Exemplo n.º 7
0
 public Task <CreatePlatformApplicationResponse> CreatePlatformApplicationAsync(CreatePlatformApplicationRequest request, CancellationToken cancellationToken = default(CancellationToken))
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 8
0
 public CreatePlatformApplicationResponse CreatePlatformApplication(CreatePlatformApplicationRequest request)
 {
     throw new System.NotImplementedException();
 }
        /// <summary>
        /// Initiates the asynchronous execution of the CreatePlatformApplication operation.
        /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/>
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the CreatePlatformApplication 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 <CreatePlatformApplicationResponse> CreatePlatformApplicationAsync(CreatePlatformApplicationRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new CreatePlatformApplicationRequestMarshaller();
            var unmarshaller = CreatePlatformApplicationResponseUnmarshaller.Instance;

            return(Invoke <IRequest, CreatePlatformApplicationRequest, CreatePlatformApplicationResponse>(request, marshaller, unmarshaller, signer, cancellationToken));
        }
Exemplo n.º 10
0
 public void CreatePlatformApplicationAsync(CreatePlatformApplicationRequest request, AmazonServiceCallback <CreatePlatformApplicationRequest, CreatePlatformApplicationResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 11
0
 public Task <CreatePlatformApplicationResponse> CreatePlatformApplicationAsync(CreatePlatformApplicationRequest request, CancellationToken cancellationToken = new CancellationToken())
 {
     throw new NotImplementedException();
 }