public async Task <RegistrationResponse> CreateRegistration(string handle) { RegistrationResponse response = new RegistrationResponse(); string newRegistrationId = null; // make sure there are no existing registrations for this push handle (used for iOS and Android) if (handle != null) { var registrations = await _hub.GetRegistrationsByChannelAsync(handle, 100); foreach (RegistrationDescription registration in registrations) { if (newRegistrationId == null) { newRegistrationId = registration.RegistrationId; } else { await _hub.DeleteRegistrationAsync(registration); } } } if (newRegistrationId == null) { newRegistrationId = await _hub.CreateRegistrationIdAsync(); } response.RegistrationId = newRegistrationId; response.IsSuccess = true; return(response); }
public async Task <RegistrationResponse> DeleteRegistration(string registrationId) { RegistrationResponse response = new RegistrationResponse(); await _hub.DeleteRegistrationAsync(registrationId); response.RegistrationId = registrationId; response.IsSuccess = true; return(response); }
public async Task <RegistrationResponse> DeviceRegistration( string registrationId, string handle, string platform, string userName) { RegistrationResponse response = new RegistrationResponse(); RegistrationDescription registration = null; switch (platform) { case "mpns": registration = new MpnsRegistrationDescription(handle); break; case "wns": registration = new WindowsRegistrationDescription(handle); break; case "apns": registration = new AppleRegistrationDescription(handle); break; case "gcm": registration = new GcmRegistrationDescription(handle); break; default: response.Errors.Add("No Platform"); response.IsSuccess = false; return(response); } registration.RegistrationId = registrationId; // add check if user is allowed to add these tags registration.Tags = new HashSet <string>(); registration.Tags.Add("username:"******"username:"******"the requested resource is no longer available"); } else { response.Errors.Add("the requested resource is no longer available"); } response.IsSuccess = false; return(response); } throw e; } response.IsSuccess = true; return(response); }