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); }
internal CreatePlatformApplicationResponse CreatePlatformApplication(CreatePlatformApplicationRequest request) { var marshaller = new CreatePlatformApplicationRequestMarshaller(); var unmarshaller = CreatePlatformApplicationResponseUnmarshaller.Instance; return(Invoke <CreatePlatformApplicationRequest, CreatePlatformApplicationResponse>(request, marshaller, unmarshaller)); }
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); } }
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 }
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); }
public Task <CreatePlatformApplicationResponse> CreatePlatformApplicationAsync(CreatePlatformApplicationRequest request, CancellationToken cancellationToken = default(CancellationToken)) { throw new System.NotImplementedException(); }
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)); }
public void CreatePlatformApplicationAsync(CreatePlatformApplicationRequest request, AmazonServiceCallback <CreatePlatformApplicationRequest, CreatePlatformApplicationResponse> callback, AsyncOptions options = null) { throw new System.NotImplementedException(); }
public Task <CreatePlatformApplicationResponse> CreatePlatformApplicationAsync(CreatePlatformApplicationRequest request, CancellationToken cancellationToken = new CancellationToken()) { throw new NotImplementedException(); }