OneSignal makes engaging customers simple and is the fastest, most reliable service to send push notifications, in-app messages, SMS, and emails.
This project demonstrates sending push notifications using the onesignal-go-api Go package. You can use this project as a boilerplate or reference to start your project.
This project assumes that you already have a OneSignal app created with push notifications setup. If you don't yet have a OneSignal app, create one first, then follow the steps below to integrate the OneSignal SDK into your Android or iOS app.
- Rename .env.example to .env,
mv .env.example .env
- Set environment variables
- Run the app,
go run .
Running this example will result in a notification being sent to all subscribed users of your OneSignal app and the following output:
╭─iamwill@kronos ~/code/@onesignalDevelopers/onesignal-go-sample ‹main●›
╰─$ go run .
Response from `CreateNotification`: &{fa7b2782-3ef7-4f44-b8f3-bba3721797a5 5 <nil> <nil> map[]}
Notification ID: fa7b2782-3ef7-4f44-b8f3-bba3721797a5
Name | Where to find it |
---|---|
APP_ID | URL in app dashboard -> https://app.onesignal.com/apps/<APP_ID> |
USER_AUTH_KEY | OneSignal profile page |
REST_API_KEY | App settings -> https://app.onesignal.com/apps/<APP_ID>/settings/keys_and_ids |
You can ask questions about the OneSignal Go API client and related topics in the onesignal-go-api repository.
🙋♂️ Ask a question
If you receive an error message or get blocked by an issue, please create a bug report!
For additional resources, please join the OneSignal Developer Community.
Get in touch with us or learn more about OneSignal through the channels below.
- Follow us on Twitter to never miss any updates from the OneSignal team, ecosystem & community
- Join us on Discord to be a part of the OneSignal Developers community, showcase your work and connect with other OneSignal developers
- Read the OneSignal Blog for the latest announcements, tutorials, in-depth articles & more.
- Subscribe to us on YouTube for walkthroughs, courses, talks, workshops & more.
- Follow us on Twitch for live streams, office hours, support & more.
Give a ⭐️ if this project helped you, and watch this repo to stay up to date.