A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
- API version: 1.3.0
- SDK version: 2.1.0
- Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen For more information, please visit https://onesignal.com
- .NET Core >=1.0
- .NET Framework >=4.6
- Mono/Xamarin >=vNext
- RestSharp - 106.13.0 or later
- Json.NET - 12.0.3 or later
- JsonSubTypes - 1.8.0 or later
- System.ComponentModel.Annotations - 5.0.0 or later
The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:
Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.
Generate the DLL using your preferred tool (e.g. dotnet build
)
Then include the DLL (under the bin
folder) in the C# project, and use the namespaces:
using OneSignalApi.Api;
using OneSignalApi.Client;
using OneSignalApi.Model;
To use the API client with a HTTP proxy, setup a System.Net.WebProxy
Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;
using System.Collections.Generic;
using System.Diagnostics;
using OneSignalApi.Api;
using OneSignalApi.Client;
using OneSignalApi.Model;
namespace Example
{
public class Example
{
public static void Main()
{
// Configure configuration with user_key Bearer token for authorization to access endpoints
// that require the OneSignal User Auth Key.
var userConfig = new Configuration();
userConfig.BasePath = "https://api.onesignal.com";
userConfig.AccessToken = "USER_AUTH_KEY";
var userInstance = new DefaultApi(userConfig);
try
{
// Create a new app
var app = new App(name: "Sample App");
var result = userInstance.CreateApp(app);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DefaultApi.CreateApp: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
// Configure configuration with app_key Bearer token for authorization to access endpoints
// that require the OneSignal App REST API Key.
var appConfig = new Configuration();
appConfig.BasePath = "https://api.onesignal.com";
appConfig.AccessToken = "REST_API_KEY";
var appInstance = new DefaultApi(appConfig);
var appId = "appId_example"; // string |
var notificationId = "notificationId_example"; // string |
try
{
// Stop a scheduled or currently outgoing notification
var result = appInstance.CancelNotification(appId, notificationId);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DefaultApi.CancelNotification: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
All URIs are relative to https://api.onesignal.com
Class | Method | HTTP request | Description |
---|---|---|---|
DefaultApi | BeginLiveActivity | POST /apps/{app_id}/live_activities/{activity_id}/token | Start Live Activity |
DefaultApi | CancelNotification | DELETE /notifications/{notification_id} | Stop a scheduled or currently outgoing notification |
DefaultApi | CreateApp | POST /apps | Create an app |
DefaultApi | CreateNotification | POST /notifications | Create notification |
DefaultApi | CreatePlayer | POST /players | Add a device |
DefaultApi | CreateSegments | POST /apps/{app_id}/segments | Create Segments |
DefaultApi | CreateSubscription | POST /apps/{app_id}/users/by/{alias_label}/{alias_id}/subscriptions | |
DefaultApi | CreateUser | POST /apps/{app_id}/users | |
DefaultApi | DeleteAlias | DELETE /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity/{alias_label_to_delete} | |
DefaultApi | DeletePlayer | DELETE /players/{player_id} | Delete a user record |
DefaultApi | DeleteSegments | DELETE /apps/{app_id}/segments/{segment_id} | Delete Segments |
DefaultApi | DeleteSubscription | DELETE /apps/{app_id}/subscriptions/{subscription_id} | |
DefaultApi | DeleteUser | DELETE /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
DefaultApi | EndLiveActivity | DELETE /apps/{app_id}/live_activities/{activity_id}/token/{subscription_id} | Stop Live Activity |
DefaultApi | ExportEvents | POST /notifications/{notification_id}/export_events?app_id={app_id} | Export CSV of Events |
DefaultApi | ExportPlayers | POST /players/csv_export?app_id={app_id} | Export CSV of Players |
DefaultApi | FetchAliases | GET /apps/{app_id}/subscriptions/{subscription_id}/user/identity | |
DefaultApi | FetchUser | GET /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
DefaultApi | FetchUserIdentity | GET /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity | |
DefaultApi | GetApp | GET /apps/{app_id} | View an app |
DefaultApi | GetApps | GET /apps | View apps |
DefaultApi | GetEligibleIams | GET /apps/{app_id}/subscriptions/{subscription_id}/iams | |
DefaultApi | GetNotification | GET /notifications/{notification_id} | View notification |
DefaultApi | GetNotificationHistory | POST /notifications/{notification_id}/history | Notification History |
DefaultApi | GetNotifications | GET /notifications | View notifications |
DefaultApi | GetOutcomes | GET /apps/{app_id}/outcomes | View Outcomes |
DefaultApi | GetPlayer | GET /players/{player_id} | View device |
DefaultApi | GetPlayers | GET /players | View devices |
DefaultApi | IdentifyUserByAlias | PATCH /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity | |
DefaultApi | IdentifyUserBySubscriptionId | PATCH /apps/{app_id}/subscriptions/{subscription_id}/user/identity | |
DefaultApi | TransferSubscription | PATCH /apps/{app_id}/subscriptions/{subscription_id}/owner | |
DefaultApi | UpdateApp | PUT /apps/{app_id} | Update an app |
DefaultApi | UpdateLiveActivity | POST /apps/{app_id}/live_activities/{activity_id}/notifications | Update a Live Activity via Push |
DefaultApi | UpdatePlayer | PUT /players/{player_id} | Edit device |
DefaultApi | UpdatePlayerTags | PUT /apps/{app_id}/users/{external_user_id} | Edit tags with external user id |
DefaultApi | UpdateSubscription | PATCH /apps/{app_id}/subscriptions/{subscription_id} | |
DefaultApi | UpdateUser | PATCH /apps/{app_id}/users/by/{alias_label}/{alias_id} |
- Model.App
- Model.BasicNotification
- Model.BasicNotificationAllOf
- Model.BasicNotificationAllOfAndroidBackgroundLayout
- Model.BeginLiveActivityRequest
- Model.Button
- Model.CancelNotificationSuccessResponse
- Model.CreateNotificationSuccessResponse
- Model.CreatePlayerSuccessResponse
- Model.CreateSegmentConflictResponse
- Model.CreateSegmentSuccessResponse
- Model.CreateSubscriptionRequestBody
- Model.CreateUserConflictResponse
- Model.CreateUserConflictResponseErrorsInner
- Model.CreateUserConflictResponseErrorsItemsMeta
- Model.DeletePlayerNotFoundResponse
- Model.DeletePlayerSuccessResponse
- Model.DeleteSegmentNotFoundResponse
- Model.DeleteSegmentSuccessResponse
- Model.DeliveryData
- Model.ExportEventsSuccessResponse
- Model.ExportPlayersRequestBody
- Model.ExportPlayersSuccessResponse
- Model.Filter
- Model.FilterExpressions
- Model.GenericError
- Model.GenericErrorErrorsInner
- Model.GetNotificationRequestBody
- Model.InlineResponse200
- Model.InlineResponse2003
- Model.InlineResponse201
- Model.InlineResponse202
- Model.InvalidIdentifierError
- Model.Notification
- Model.Notification200Errors
- Model.NotificationAllOf
- Model.NotificationHistorySuccessResponse
- Model.NotificationSlice
- Model.NotificationTarget
- Model.NotificationWithMeta
- Model.NotificationWithMetaAllOf
- Model.Operator
- Model.OutcomeData
- Model.OutcomesData
- Model.PlatformDeliveryData
- Model.PlatformDeliveryDataEmailAllOf
- Model.PlatformDeliveryDataSmsAllOf
- Model.Player
- Model.PlayerNotificationTarget
- Model.PlayerNotificationTargetIncludeAliases
- Model.PlayerSlice
- Model.PropertiesDeltas
- Model.PropertiesObject
- Model.Purchase
- Model.RateLimiterError
- Model.Segment
- Model.SegmentNotificationTarget
- Model.StringMap
- Model.SubscriptionObject
- Model.TransferSubscriptionRequestBody
- Model.UpdateLiveActivityRequest
- Model.UpdateLiveActivitySuccessResponse
- Model.UpdatePlayerSuccessResponse
- Model.UpdatePlayerTagsRequestBody
- Model.UpdatePlayerTagsSuccessResponse
- Model.UpdateSubscriptionRequestBody
- Model.UpdateUserRequest
- Model.User
- Model.UserIdentityRequestBody
- Model.UserIdentityResponse
- Model.UserSubscriptionOptions
- Type: Bearer Authentication
- Type: Bearer Authentication