OneSignal
- API version: 1.4.0
- Build date: 2025-02-20T21:54:45.185Z[Etc/UTC]
A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
For more information, please visit https://onesignal.com
Automatically generated by the OpenAPI Generator
Building the API client library requires:
- Java 1.8+
- Maven (3.8.3+)/Gradle (7.2+)
To install the API client library to your local Maven repository, simply execute:
mvn clean installTo deploy it to a remote Maven repository instead, configure the settings of the repository and execute:
mvn clean deployRefer to the OSSRH Guide for more information.
Add this dependency to your project's POM:
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>onesignal-java-client</artifactId>
<version>1.4.0</version>
<scope>compile</scope>
</dependency>Add this dependency to your project's build file:
repositories {
mavenCentral() // Needed if the 'onesignal-java-client' jar has been published to maven central.
mavenLocal() // Needed if the 'onesignal-java-client' jar has been published to the local maven repo.
}
dependencies {
implementation "org.openapitools:onesignal-java-client:1.4.0"
}At first generate the JAR by executing:
mvn clean packageThen manually install the following JARs:
target/onesignal-java-client-1.4.0.jartarget/lib/*.jar
Please follow the installation instruction and execute the following Java code:
// Import classes:
import com.onesignal.client.ApiClient;
import com.onesignal.client.ApiException;
import com.onesignal.client.Configuration;
import com.onesignal.client.auth.*;
import com.onesignal.client.models.*;
import com.onesignal.client.api.DefaultApi;
public class Example {
private static final String appId = "YOUR_APP_ID";
private static final String appKeyToken = "YOUR_APP_KEY";
private static final String userKeyToken = "YOUR_USER_TOKEN";
private static Notification createNotification() {
Notification notification = new Notification();
notification.setAppId(appId);
notification.setIsChrome(true);
notification.setIsAnyWeb(true);
notification.setIncludedSegments(Arrays.asList(new String[]{"Subscribed Users"}));
StringMap contentStringMap = new StringMap();
contentStringMap.en("Test");
notification.setContents(contentStringMap);
return notification;
}
public static void main(String[] args) {
// Setting up the client
ApiClient defaultClient = Configuration.getDefaultApiClient();
HttpBearerAuth appKey = (HttpBearerAuth) defaultClient.getAuthentication("app_key");
appKey.setBearerToken(appKeyToken);
HttpBearerAuth userKey = (HttpBearerAuth) defaultClient.getAuthentication("user_key");
userKey.setBearerToken(userKeyToken);
api = new DefaultApi(defaultClient);
// Setting up the notification
Notification notification = createNotification();
// Sending the request
CreateNotificationSuccessResponse response = api.createNotification(notification);
// Checking the result
System.out.print(response.getId();
}
}All URIs are relative to https://api.onesignal.com
- App
- BasicNotification
- BasicNotificationAllOf
- BasicNotificationAllOfAndroidBackgroundLayout
- BeginLiveActivityRequest
- Button
- CancelNotificationSuccessResponse
- CreateNotificationSuccessResponse
- CreatePlayerSuccessResponse
- CreateSegmentConflictResponse
- CreateSegmentSuccessResponse
- CreateSubscriptionRequestBody
- CreateUserConflictResponse
- CreateUserConflictResponseErrorsInner
- CreateUserConflictResponseErrorsItemsMeta
- DeletePlayerNotFoundResponse
- DeletePlayerSuccessResponse
- DeleteSegmentNotFoundResponse
- DeleteSegmentSuccessResponse
- DeliveryData
- ExportEventsSuccessResponse
- ExportPlayersRequestBody
- ExportPlayersSuccessResponse
- Filter
- FilterExpressions
- GenericError
- GenericErrorErrorsInner
- GetNotificationRequestBody
- InlineResponse200
- InlineResponse2003
- InlineResponse201
- InlineResponse202
- InvalidIdentifierError
- Notification
- Notification200Errors
- NotificationAllOf
- NotificationHistorySuccessResponse
- NotificationSlice
- NotificationTarget
- NotificationWithMeta
- NotificationWithMetaAllOf
- Operator
- OutcomeData
- OutcomesData
- PlatformDeliveryData
- PlatformDeliveryDataEmailAllOf
- PlatformDeliveryDataSmsAllOf
- Player
- PlayerNotificationTarget
- PlayerNotificationTargetIncludeAliases
- PlayerSlice
- PropertiesDeltas
- PropertiesObject
- Purchase
- RateLimiterError
- Segment
- SegmentNotificationTarget
- StringMap
- SubscriptionObject
- TransferSubscriptionRequestBody
- UpdateLiveActivityRequest
- UpdateLiveActivitySuccessResponse
- UpdatePlayerSuccessResponse
- UpdatePlayerTagsRequestBody
- UpdatePlayerTagsSuccessResponse
- UpdateSubscriptionRequestBody
- UpdateUserRequest
- User
- UserIdentityRequestBody
- UserIdentityResponse
- UserSubscriptionOptions
Authentication schemes defined for the API:
- Type: HTTP basic authentication
- Type: HTTP basic authentication
It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.
