Skip to content

Commit

Permalink
Fix undefined variable bug
Browse files Browse the repository at this point in the history
See [issue#2](#2) for more details
  • Loading branch information
iAmWillShepherd committed Sep 21, 2022
1 parent 1c6c6d6 commit a7b3213
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ import (

var configuration = onesignal.NewConfiguration()
var apiClient = onesignal.NewAPIClient(configuration)
var osAuthCtx = context.WithValue(
context.Background(),
onesignal.AppAuth,
os.Getenv("REST_API_KEY"),
)

func PushNotification() {
fmt.Fprintf(os.Stdout, "oAuthCtx: %v\n", osAuthCtx)

notification := *onesignal.NewNotification(os.Getenv("APP_ID"))
appId := os.Getenv("APP_ID")
restApiKey := os.Getenv("REST_API_KEY")
osAuthCtx := context.WithValue(
context.Background(),
onesignal.AppAuth,
restApiKey,
)

notification := *onesignal.NewNotification(appId)
notification.SetIncludedSegments([]string{"Subscribed Users"})
notification.SetIsIos(false)
message := "Go Test Notification"
stringMap := onesignal.StringMap{En: &message}
notification.Contents = *onesignal.NewNullableStringMap(&stringMap)

resp, r, err := apiClient.DefaultApi.CreateNotification(osAuthCtx).Notification(notification).Execute()

Expand All @@ -31,4 +36,5 @@ func PushNotification() {
}

fmt.Fprintf(os.Stdout, "Response from `CreateNotification`: %v\n", resp)
fmt.Fprintf(os.Stdout, "Notification ID: %v\n", resp.GetId())
}

0 comments on commit a7b3213

Please sign in to comment.