Code Monkey home page Code Monkey logo

onesignal-java-api's Introduction

onesignal-java-client

OneSignal

  • API version: 1.2.2
    • Build date: 2023-08-01T23:27:12.168Z[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

Requirements

Building the API client library requires:

  1. Java 1.8+
  2. Maven (3.8.3+)/Gradle (7.2+)

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

mvn clean deploy

Refer to the OSSRH Guide for more information.

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>org.openapitools</groupId>
  <artifactId>onesignal-java-client</artifactId>
  <version>1.2.2</version>
  <scope>compile</scope>
</dependency>

Gradle users

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.2.2"
  }

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/onesignal-java-client-1.2.2.jar
  • target/lib/*.jar

Getting Started

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();
  }
}

Documentation for API Endpoints

All URIs are relative to https://onesignal.com/api/v1

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}

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

app_key

  • Type: HTTP basic authentication

user_key

  • Type: HTTP basic authentication

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Author

[email protected]

onesignal-java-api's People

Contributors

jkasten2 avatar jmadler avatar kesheshyan avatar onesignal-deploy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onesignal-java-api's Issues

[Bug]:

What happened?

I added implementation ("org.openapitools:onesignal-java-client:1.0.1") in my gradle file on Android Studio. But error was occured.

Steps to reproduce?

Duplicate class javax.ws.rs.ApplicationPath found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.Consumes found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.CookieParam found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.DELETE found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.DefaultValue found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.Encoded found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.FormParam found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.GET found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.HEAD found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.HeaderParam found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.HttpMethod found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.MatrixParam found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.OPTIONS found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.POST found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.PUT found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.Path found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.PathParam found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.Produces found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.QueryParam found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.WebApplicationException found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Application found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.CacheControl found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Context found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Cookie found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.EntityTag found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.GenericEntity found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.HttpHeaders found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.MediaType found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.MediaType$1 found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.MultivaluedMap found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.NewCookie found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.PathSegment found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Request found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Response found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Response$ResponseBuilder found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Response$Status found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Response$Status$Family found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Response$StatusType found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.SecurityContext found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.StreamingOutput found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.UriBuilder found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.UriBuilderException found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.UriInfo found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Variant found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.core.Variant$VariantListBuilder found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.ext.ContextResolver found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.ext.ExceptionMapper found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.ext.FactoryFinder found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.ext.MessageBodyReader found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.ext.MessageBodyWriter found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.ext.Provider found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.ext.Providers found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.ext.RuntimeDelegate found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)
Duplicate class javax.ws.rs.ext.RuntimeDelegate$HeaderDelegate found in modules javax.ws.rs-api-2.1 (javax.ws.rs:javax.ws.rs-api:2.1.1) and jsr311-api-1.1 (javax.ws.rs:jsr311-api:1.1.1)

Go to the documentation to learn how to Fix dependency resolution errors
  • I agree to follow this project's Code of Conduct

[question]: Device detection

How can we help?

What are people using for device detection to send in a device_type?

Code of Conduct

  • I agree to follow this project's Code of Conduct

[question]: How do I SET external_user_id?

How can we help?

I can't seem to find documentation on how to set the external_user_id in OneSignal. Is it available?

Code of Conduct

  • I agree to follow this project's Code of Conduct

Parse exception for getNotifications

Hello, when the response contains a "buttons" object the json string can not be parsed.
https://github.com/OneSignal/onesignal-java-api/blob/main/docs/DefaultApi.md#getNotifications

Example response:
"buttons": "[{"id":"declineFriend","text":"Decline"},{"id":"acceptFriend","text":"Accept"}]",

Error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at path $.buttons

Tested in version 'org.openapitools:onesignal-java-client:1.2.1'

[Bug]: NPE on ApiException.getMessage()

What happened?

When an ApiException is thrown and exception.printStackTrace() or just exception.getMessage() is called, then a NullPointerException is thrown due to this line in the getMessage() function implementation:

public String getMessage() {
        return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders().toString());
    }

If this.getResponseHeaders() is null, then .toString() throws NPE.

Steps to reproduce?

When sending a notification fails:

apiClient.createNotificationAsync(
                notification,
                new ApiCallback<>() {
                    @Override
                    public void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
                        logger.info("Notification send failed with status code: "+ statusCode);
                        if(e != null) e.printStackTrace();
                    }

                    @Override
                    public void onSuccess(CreateNotificationSuccessResponse result, int statusCode, Map<String, List<String>> responseHeaders) {
                        System.out.println("Push notification sent: " + result.toJson());
                    }

                    @Override
                    public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {

                    }

                    @Override
                    public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {

                    }
                }
            );

What did you expect to happen?

exception.printStackTrace() or exception.getMessage() should not throw NPE.

Relevant log output

Exception in thread "OkHttp Dispatcher" java.lang.NullPointerException: Cannot invoke "java.util.Map.toString()" because the return value of "com.onesignal.client.ApiException.getResponseHeaders()" is null
	at com.onesignal.client.ApiException.getMessage(ApiException.java:164)
	at java.base/java.lang.Throwable.getLocalizedMessage(Throwable.java:397)
	at java.base/java.lang.Throwable.toString(Throwable.java:496)
	at java.base/java.lang.String.valueOf(String.java:4218)
	at java.base/java.io.PrintStream.println(PrintStream.java:1047)
	at java.base/java.lang.Throwable$WrappedPrintStream.println(Throwable.java:763)
	at java.base/java.lang.Throwable.printStackTrace(Throwable.java:670)
	at java.base/java.lang.Throwable.printStackTrace(Throwable.java:659)
	at java.base/java.lang.Throwable.printStackTrace(Throwable.java:650)
	at com.myapp.backend.notification.client.NotificationClient$2.onFailure(NotificationClient.java:97)
	at com.onesignal.client.ApiClient$1.onResponse(ApiClient.java:1038)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Bug]: There is an interesting bug on viewdevices api

What happened?

When i entered my apikey with more than one character, api returns success.

For example:
my app id: correct
my api key: correctx

(I put my api key plus x)

Steps to reproduce?

1. Run this api with below info. https://onesignal.com/api/v1/players?app_id=<my-app-id>&limit=300&offset=0
2. Enter correct app id
3. Enter correct api key + one character
4. And run

What did you expect to happen?

It should an error soemthing like below:
"Please include a case-sensitive header of Authorization: Basic or Bearer token="" with a valid REST API key."

image
image

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

[question]:

How can we help?

Hi,

How does one pass the filter object to the notification?

Code of Conduct

  • I agree to follow this project's Code of Conduct

[Bug]: okhttp3 exception

What happened?

The latest version of the API library throws an exception when creating a notification with this line
CreateNotificationSuccessResponse result = apiInstance.createNotification(notification);

@Value(value = "${app.onesignal.appid}")
private static String appId;

@Value(value = "${app.onesignal.restapikey}")
private static String appKeyToken;

@Value(value = "${app.onesignal.userauthkey}")
private static String userKeyToken;

private static Notification createNotification() {
    Notification notification = new Notification();
    notification.setAppId(appId);
    List<String> segments = new ArrayList<>();
    segments.add("Subscribed Users");
    notification.includedSegments(segments);
    notification.setIsAndroid(true);
    notification.setAndroidAccentColor("FFFFC733");
    notification.smallIcon("ic_stat_onesignal_default");
    StringMap contentStringMap = new StringMap();
    contentStringMap.en("Test body");

    StringMap headinMap = new StringMap();
    headinMap.en("Title");

    notification.setContents(contentStringMap);
    notification.setHeadings(headinMap);
    return notification;
}

public void send(){
    // 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);
    DefaultApi apiInstance = new DefaultApi(defaultClient);

    // Setting up the notification
    Notification notification = createNotification();

    try {
        CreateNotificationSuccessResponse result = apiInstance.createNotification(notification);
        System.out.println(result);
    } catch (ApiException e) {
        System.err.println("Exception when calling DefaultApi#createNotification");
        System.err.println("Status code: " + e.getCode());
        System.err.println("Reason: " + e.getResponseBody());
        System.err.println("Response headers: " + e.getResponseHeaders());
        e.printStackTrace();
    }
}

Steps to reproduce?

1. clone the repository
2. run mvnw clean install
3. add the maven dependency to my Spring project v 2.6.7
4. execute the above method

What did you expect to happen?

expected the API to return HTTP 200

Relevant log output

java.lang.NoSuchMethodError: 'okhttp3.RequestBody okhttp3.RequestBody.create(java.lang.String, okhttp3.MediaType)'
	at com.onesignal.client.ApiClient.serialize(ApiClient.java:900)
	at com.onesignal.client.ApiClient.buildRequest(ApiClient.java:1151)
	at com.onesignal.client.ApiClient.buildCall(ApiClient.java:1103)
	at com.onesignal.client.api.DefaultApi.createNotificationCall(DefaultApi.java:434)
	at com.onesignal.client.api.DefaultApi.createNotificationValidateBeforeCall(DefaultApi.java:446)
	at com.onesignal.client.api.DefaultApi.createNotificationWithHttpInfo(DefaultApi.java:483)
	at com.onesignal.client.api.DefaultApi.createNotification(DefaultApi.java:465)
	at com.exemple.service.impl.PushTest.send(PushTest.java:74)

Code of Conduct

  • I agree to follow this project's Code of Conduct

[question]: How can I use the "include_aliases" field with an "external_id" array in it while creating a notification ?

How can we help?

As the documentation indicates, it is now deprecated to use "include_external_user_ids" while creating a notification. We should use "include_aliases" with an "external_id" field that will contain an array of external ids.

But, when I try to do so using the Java SDK, it does not look like its possible to supply the "external_id" field to the PlayerNotificationTargetIncludeAliases object required by the includeAliases field of a Notification object.

The field seams to be hardcoded to "alias_label".

Is there a workaround or am I misunderstanding something ?

Thanks in advance

Code of Conduct

  • I agree to follow this project's Code of Conduct

[question]: how show or access to swagger docs

How can we help?

i checked the code from onesignal-java-api has the swagger annotations, I would like to know how check or access to documentation, non java documentation.?

Code of Conduct

  • I agree to follow this project's Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.