public async Task <EmptyApiResponse> DeleteChannels() { var client = new IpMessagingClient(settings.Account.Sid, settings.AuthToken); var channels = client.ListChannels(settings.IpMessaging.Service.Sid).Channels; channels.ForEach(channel => client.DeleteChannel(settings.IpMessaging.Service.Sid, channel.Sid)); return(new EmptyApiResponse()); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; const string serviceSid = "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string channelSid = "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; // Delete a Channel var client = new IpMessagingClient(accountSid, authToken); DeleteStatus status = client.DeleteChannel(serviceSid, channelSid); Console.WriteLine(status); }
public IActionResult Delete(int id) { var friend = _db.Friends.FirstOrDefault(s => s.FriendId == id); if (friend == null) { return(HttpNotFound()); } else { // Delete channel _client.DeleteChannel(Environment.GetEnvironmentVariable("TWILIO_IPM_SERVICE_SID"), friend.ChannelSid); _client.DeleteUser(Environment.GetEnvironmentVariable("TWILIO_IPM_SERVICE_SID"), friend.UserSid); // Remove user from from the database _db.Friends.Remove(friend); _db.SaveChanges(); return(RedirectToAction("Index")); } }