33A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
44
55- API version: 5.8.0
6- - Package version: 5.8.0
6+ - Package version: 5.8.1
77
88## Installation
99
@@ -21,7 +21,7 @@ Every SDK requires authentication via API keys. Two key types are available:
2121> ** Warning:** Store your API keys in environment variables or a secrets manager. Never commit them to source control.
2222
2323``` go
24- import onesignal " github.com/OneSignal/onesignal-go-api"
24+ import onesignal " github.com/OneSignal/onesignal-go-api/v5 "
2525
2626restAuth := context.WithValue (
2727 context.Background (),
@@ -42,14 +42,14 @@ apiClient := onesignal.NewAPIClient(onesignal.NewConfiguration())
4242
4343``` go
4444notification := *onesignal.NewNotification (" YOUR_APP_ID" )
45- notification.SetContents (onesignal.StringMap {En: onesignal.PtrString (" Hello from OneSignal!" )})
46- notification.SetHeadings (onesignal.StringMap {En: onesignal.PtrString (" Push Notification" )})
45+ notification.SetContents (onesignal.LanguageStringMap {En: onesignal.PtrString (" Hello from OneSignal!" )})
46+ notification.SetHeadings (onesignal.LanguageStringMap {En: onesignal.PtrString (" Push Notification" )})
4747notification.SetIncludedSegments ([]string {" Subscribed Users" })
4848
49- response , _ , err := apiClient.DefaultApi
50- . CreateNotification (orgAuth)
51- . Notification (notification)
52- . Execute ()
49+ response , _ , err := apiClient.DefaultApi .
50+ CreateNotification (orgAuth).
51+ Notification (notification).
52+ Execute ()
5353
5454if err != nil {
5555 log.Fatal (err)
@@ -64,27 +64,27 @@ notification := *onesignal.NewNotification("YOUR_APP_ID")
6464notification.SetEmailSubject (" Important Update" )
6565notification.SetEmailBody (" <h1>Hello!</h1><p>This is an HTML email.</p>" )
6666notification.SetIncludedSegments ([]string {" Subscribed Users" })
67- notification.SetChannelForExternalUserIds (" email" )
67+ notification.SetTargetChannel (" email" )
6868
69- response , _ , err := apiClient.DefaultApi
70- . CreateNotification (orgAuth)
71- . Notification (notification)
72- . Execute ()
69+ response , _ , err := apiClient.DefaultApi .
70+ CreateNotification (orgAuth).
71+ Notification (notification).
72+ Execute ()
7373```
7474
7575## Send an SMS
7676
7777``` go
7878notification := *onesignal.NewNotification (" YOUR_APP_ID" )
79- notification.SetContents (onesignal.StringMap {En: onesignal.PtrString (" Your SMS message content here" )})
79+ notification.SetContents (onesignal.LanguageStringMap {En: onesignal.PtrString (" Your SMS message content here" )})
8080notification.SetIncludedSegments ([]string {" Subscribed Users" })
81- notification.SetChannelForExternalUserIds (" sms" )
81+ notification.SetTargetChannel (" sms" )
8282notification.SetSmsFrom (" +15551234567" )
8383
84- response , _ , err := apiClient.DefaultApi
85- . CreateNotification (orgAuth)
86- . Notification (notification)
87- . Execute ()
84+ response , _ , err := apiClient.DefaultApi .
85+ CreateNotification (orgAuth).
86+ Notification (notification).
87+ Execute ()
8888```
8989
9090## Full API reference
0 commit comments