Push notifications are a crucial communication tool for mobile apps, helping developers keep users informed. For apps with a global user base, localizing push notifications in multiple languages can be challenging and time-consuming. In this guide, we show you how to automate the translation and distribution of multi-language push notifications using Gridly and OneSignal—streamlining the process and ensuring timely delivery of messages to users in their preferred language.
What’s covered:
- Setting up OneSignal push notifications
- Automating translation and API requests with Gridly
- Sending multi-language push notifications
- Final thoughts
Setting up OneSignal push notifications
Here is how we set up OneSignal push notifications for your mobile application:
Step 1. Create an account: Sign up for an account here.
Step 2. Create a new app: With your new account create a new OneSignal app and choose your preferred channel. For this article, we will use Google Android (FCM).
Step 3. Upload Service Account JSON: Retrieve your Service Account JSON file from Firebase Console. Refer to this OneSignal guide for detailed instructions.
Step 4. Select SDK: Choose Native Android as your SDK.
Step 5. Install OneSignal Android SDK: Follow this guide to install the OneSignal Android SDK on your mobile app. After installation, OneSignal will be able to detect the user’s operating system language and save it as their language preference.
Step 6. Retrieve credentials: You can also find your OneSignal API key and App ID in Settings > Keys & IDs. This information is unique to you and should be kept private.
Automating translation and API request swith Gridly
To achieve our goal, we need to configure two Automations in Gridly capable of:
- Translating notification content
- Sending source and translated content as requests to the OneSignal API
First, sign up for a 14-day free trial Gridly account. This will grant you access to the necessary features for this tutorial. Next, create a new project and your first localization Grid. Add your source language and target languages. Make sure to cover all the major languages of your users.
Inside your Grid, create the first Automation to translate content:
- Select Record updated as the trigger, watching the source language column.
- Select Google loc translate. Add the source language and target language columns.
Activate and verify if the automated translation works by inserting content into the source language column. If it works correctly, we can move on to the second Automation:
- Select Manual record trigger as the trigger.
- Select Send web request and configure the settings:
- HTTP method: POST
- URL: https://api.onesignal.com/notifications
- Header: Authorization Basic (insert your OneSignal API key)
- Payload: Structure the payload as follows. The “app_id” value is your OneSignal App ID. “contents” includes the language codes of source and target languages, then select corresponding columns as values.
To run this Automation, right click on the row containing your notification, click Run Automations and select it from the list.
Sending multi-language push notifications
- Enter your message in the source language column of the Gridly interface or via the Gridly API.
- The first automation will translate the content into the target languages.
- Run the second automation to send the source and translated content to OneSignal.
- OneSignal push notifications will be distributed based on the user’s system language (e.g., English users receive “en” content, Polish users receive “pl” content).
Let’s send a sample notification. Enter the message in your source language field.
When the translation is complete, run the web request Automation. Users will receive notifications based on their system language.
Final thoughts
In this article, we have built a workflow in Gridly to automate the translation and sending of OneSignal push notifications to your mobile app users. It reduces the time and efforts needed for manual translation and distribution. To improve upon this result, consider these next steps: