Skip to content
Merged
Show file tree
Hide file tree
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
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

- API version: 5.8.0
- Package version: 5.8.0
- Package version: 5.8.1

## Installation

Expand All @@ -21,7 +21,7 @@ Every SDK requires authentication via API keys. Two key types are available:
> **Warning:** Store your API keys in environment variables or a secrets manager. Never commit them to source control.

```go
import onesignal "github.com/OneSignal/onesignal-go-api"
import onesignal "github.com/OneSignal/onesignal-go-api/v5"

restAuth := context.WithValue(
context.Background(),
Expand All @@ -42,14 +42,14 @@ apiClient := onesignal.NewAPIClient(onesignal.NewConfiguration())

```go
notification := *onesignal.NewNotification("YOUR_APP_ID")
notification.SetContents(onesignal.StringMap{En: onesignal.PtrString("Hello from OneSignal!")})
notification.SetHeadings(onesignal.StringMap{En: onesignal.PtrString("Push Notification")})
notification.SetContents(onesignal.LanguageStringMap{En: onesignal.PtrString("Hello from OneSignal!")})
notification.SetHeadings(onesignal.LanguageStringMap{En: onesignal.PtrString("Push Notification")})
notification.SetIncludedSegments([]string{"Subscribed Users"})

response, _, err := apiClient.DefaultApi
.CreateNotification(orgAuth)
.Notification(notification)
.Execute()
response, _, err := apiClient.DefaultApi.
CreateNotification(orgAuth).
Notification(notification).
Execute()

if err != nil {
log.Fatal(err)
Expand All @@ -64,27 +64,27 @@ notification := *onesignal.NewNotification("YOUR_APP_ID")
notification.SetEmailSubject("Important Update")
notification.SetEmailBody("<h1>Hello!</h1><p>This is an HTML email.</p>")
notification.SetIncludedSegments([]string{"Subscribed Users"})
notification.SetChannelForExternalUserIds("email")
notification.SetTargetChannel("email")

response, _, err := apiClient.DefaultApi
.CreateNotification(orgAuth)
.Notification(notification)
.Execute()
response, _, err := apiClient.DefaultApi.
CreateNotification(orgAuth).
Notification(notification).
Execute()
```

## Send an SMS

```go
notification := *onesignal.NewNotification("YOUR_APP_ID")
notification.SetContents(onesignal.StringMap{En: onesignal.PtrString("Your SMS message content here")})
notification.SetContents(onesignal.LanguageStringMap{En: onesignal.PtrString("Your SMS message content here")})
notification.SetIncludedSegments([]string{"Subscribed Users"})
notification.SetChannelForExternalUserIds("sms")
notification.SetTargetChannel("sms")
notification.SetSmsFrom("+15551234567")

response, _, err := apiClient.DefaultApi
.CreateNotification(orgAuth)
.Notification(notification)
.Execute()
response, _, err := apiClient.DefaultApi.
CreateNotification(orgAuth).
Notification(notification).
Execute()
```

## Full API reference
Expand Down
2 changes: 1 addition & 1 deletion configuration.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading