Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve README and Example class #32

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Building the API client library requires:

## Installation

First, clone the repo, simply execute:

```shell
git clone https://github.com/OneSignal/onesignal-java-api.git
```

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

```shell
Expand All @@ -35,7 +41,7 @@ Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) f

### Maven users

Add this dependency to your project's POM:
After you build and install to your local Maven repo ou deploy to the project repository, add this dependency to your project's POM:

```xml
<dependency>
Expand Down Expand Up @@ -81,11 +87,14 @@ Please follow the [installation](#installation) instruction and execute the foll
```java

// Import classes:
import java.util.Arrays;
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.model.CreateNotificationSuccessResponse;
import com.onesignal.client.model.Notification;
import com.onesignal.client.model.StringMap;
import com.onesignal.client.api.DefaultApi;

public class Example {
Expand All @@ -106,14 +115,14 @@ public class Example {
return notification;
}

public static void main(String[] args) {
public static void main(String[] args) throws ApiException {
// 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);
DefaultApi api = new DefaultApi(defaultClient);

// Setting up the notification
Notification notification = createNotification();
Expand All @@ -122,7 +131,7 @@ public class Example {
CreateNotificationSuccessResponse response = api.createNotification(notification);

// Checking the result
System.out.print(response.getId();
System.out.print(response.getId());
}
}

Expand Down