DeleteEndpoint() 공개 메소드

Deletes the endpoint for a device and mobile app from Amazon SNS. This action is idempotent. For more information, see Using Amazon SNS Mobile Push Notifications.

When you delete an endpoint that is also subscribed to a topic, then you must also unsubscribe the endpoint from the topic.

/// Indicates that the user has been denied access to the requested resource. /// /// Indicates an internal service error. /// /// Indicates that a request parameter does not comply with the associated constraints. ///
public DeleteEndpoint ( DeleteEndpointRequest request ) : Amazon.SimpleNotificationService.Model.DeleteEndpointResponse
request Amazon.SimpleNotificationService.Model.DeleteEndpointRequest Container for the necessary parameters to execute the DeleteEndpoint service method.
리턴 Amazon.SimpleNotificationService.Model.DeleteEndpointResponse
예제 #1
0
    public static void SNSMobilePushAPIsDeletePlatformEndpoint()
    {
      #region SNSMobilePushAPIsDeletePlatformEndpoint
      var snsClient = new AmazonSimpleNotificationServiceClient();

      var request = new DeleteEndpointRequest
      {
        EndpointArn = "arn:aws:sns:us-east-1:80398EXAMPLE:" +
          "endpoint/GCM/TimeCardProcessingApplication/" +
          "d84b5f0d-7136-3bbe-9b42-4e001EXAMPLE"
      };

      snsClient.DeleteEndpoint(request);
      #endregion
    }
        public void DeleteEndpoint(string endpointarn)
        {
            try
            {
                using (var snsclient = new AmazonSimpleNotificationServiceClient(_accesskey, _secretkey))
                {
                    snsclient.DeleteEndpoint(new DeleteEndpointRequest()
                    {
                        EndpointArn = endpointarn
                    });
                }

            }
            catch (Exception ex)
            {
                throw new Exception("DeleteEndpoint " + ex.Message);
            }
        }
예제 #3
0
        /// <summary>
        /// This is the main function for sending notification
        /// </summary>
        public void sendNotification()
        {
            foreach (Client client in clients)
            {
                int clientID = client.getClientID();

                #region AWS connection - This code block is same for every push message type - This is the basic block.

                _client = new AmazonSimpleNotificationServiceClient("XXXXXXX", "XXXXXXXXXX", Amazon.RegionEndpoint.EUCentral1);
                string    token       = client.getPushToken();
                Platfroms mobilOsType = client.getMobileType() == 0 ? Platfroms.IOS_PATFORM : Platfroms.ANDROID_PLATFORM;

                try
                {
                    string applicationArn = "";

                    try
                    {
                        applicationArn = applications[(int)mobilOsType].getArn();
                    }
                    catch
                    {
                        continue;
                    }

                    string endPointArn = createEndPointArn(token, applicationArn);

                    if (string.IsNullOrEmpty(endPointArn))
                    {
                        continue;
                    }
                    else
                    {
                        PublishRequest publishRequest          = new PublishRequest();
                        Dictionary <string, string> messageMap = new Dictionary <string, string>();
                        messageMap.Add("default", "default message");
                        string platform = mobilOsType == 0 ? "APNS_SANDBOX" : "GCM";

                        // This application developed for IOS and Android
                        if (mobilOsType != Platfroms.IOS_PATFORM && mobilOsType != Platfroms.ANDROID_PLATFORM)
                        {
                            continue;
                        }

                        int    clientsID = client.getClientID();
                        Guid   pushesID  = client.getPushID();
                        string message   = mobilOsType == 0 ? getAPNSMessage(notification, title, pushesID, clientsID) : getGCMMessage(notification, title, pushesID, clientsID);
                        messageMap.Add(platform, message);

                        publishRequest.TargetArn        = endPointArn;
                        publishRequest.MessageStructure = "json";

                        string messageJSON = "";

                        try
                        {
                            messageJSON = JsonConvert.SerializeObject(messageMap);
                        }
                        catch
                        {
                            continue;
                        }

                        try
                        {
                            publishRequest.Message = messageJSON;
                            _client.Publish(publishRequest);
                        }
                        catch
                        {
                            continue;
                        }

                        try
                        {
                            // for deleting endPointArn
                            DeleteEndpointRequest _request = new DeleteEndpointRequest();
                            _request.EndpointArn = endPointArn;
                            _client.DeleteEndpoint(_request);
                        }
                        catch
                        {
                            continue;
                        }
                    }
                }
                catch
                {
                    continue;
                }

                #endregion
            }
        }