/// <summary> /// Edits existing device defined in OneSignal App. /// </summary> /// <param name="id"> Id of the device </param> /// <param name="options"> Options used to modify attributes of the device. </param> /// <exception cref="Exception"></exception> public async Task EditAsync(string id, DeviceEditOptions options) { var result = await ApiUri.AppendPathSegment($"players/{id}") .WithHeader("Authorization", $"Basic {ApiKey}") .PutJsonAsync(options) .ConfigureAwait(true); }
/// <summary> /// Cancel a notification scheduled by the OneSignal system /// </summary> /// <param name="options"> Options used for notification cancel operation. </param> /// <returns></returns> public async Task <NotificationCancelResult> CancelAsync(NotificationCancelOptions options) { var result = await ApiUri.AppendPathSegment($"notifications/{options.Id}?app_id={options.AppId}") .WithHeader("Authorization", $"Basic {ApiKey}") .DeleteAsync() .ReceiveJson <NotificationCancelResult>() .ConfigureAwait(true); return(result); }
/// <summary> /// Adds new device into OneSignal App. /// </summary> /// <param name="options"> Here you can specify options used to add new device. </param> /// <returns> Result of device add operation. </returns> public async Task <DeviceAddResult> AddAsync(DeviceAddOptions options) { var result = await ApiUri.AppendPathSegment("players") .WithHeader("Authorization", $"Basic {ApiKey}") .PostJsonAsync(options) .ReceiveJson <DeviceAddResult>() .ConfigureAwait(true); return(result); }
/// <inheritdoc /> /// <summary> /// Creates new notification to be sent by OneSignal system. /// </summary> /// <param name="options"> Options used for notification create operation. </param> /// <returns></returns> public async Task <NotificationCreateResult> CreateAsync(NotificationCreateOptions options) { var result = await ApiUri.AppendPathSegment("notifications") .WithHeader("Authorization", $"Basic {ApiKey}") .PostJsonAsync(options) .ReceiveJson <NotificationCreateResult>() .ConfigureAwait(true); return(result); }
public async Task <DeviceInfo> GetAsync(string playerId, string appId) { try { var result = await ApiUri .AppendPathSegment($"players/{playerId}") .SetQueryParam("app_id", appId) .WithHeader("Authorization", $"Basic {ApiKey}") .GetJsonAsync <DeviceInfo>() .ConfigureAwait(true); return(result); } catch (Exception) { return(null); } }