Links

Push Notification Blocks

Overview

Push notifications are one of the biggest advantages of mobile apps over mobile websites since they can send messages to users without the app being open.
When a user first opens an app with push notifications enabled they receive an alert prompting them to enable push notifications. Once they accept they are a subscriber of your app's push notifications.

Thunkable + OneSignal

Thunkable utilizes the services of OneSignal to facilitate push notifications from your app. OneSignal is a free service that supports unlimited devices and notifications. You can learn more about their features here: OneSignal pricing page.
To send push notifications to your app's users, you must link your Thunkable app to your OneSignal apps (iOS and/or Android). Once you've added your OneSignal App IDs into Thunkable, the work in Thunkable is done, and the remainder of the management takes place in third-party platforms (OneSignal, Apple Developer, and Firebase, depending on the platform).
Push Notifications are available on Thunkable Pro, Business, and Team plans. While all Creators can add Push Notifications to their projects and live test them in their Android apps, only Creators on the previously mentioned plans can download and publish apps with Push Notifications. See our pricing page for more details.

Push Notification Best Practices

Notifications that are irrelevant and too frequent are often dismissed or blocked. We highly recommend sending notifications only when the content is relevant to the user. Examples include an e-commerce app letting the user know about a sale, or a game app letting the user know about a new level or feature.

Add Push Notifications to your app

To add Push Notifications to your app :
  1. 1.
    Navigate to your project's Blocks tab.
  2. 2.
    Locate Push Notification under the App Features heading.
  3. 3.
    Click the gear icon next to Push Notification.
  4. 4.
    The Push Notification settings modal opens. This is where you will enter your OneSignal Android App ID and OneSignal iOS App ID to configure the connection between OneSignal and your Thunkable project.
    Geolocation Permissions - OneSignal allows you to push messages to users based on their location. In order to do that, you need permission from your users to register their location. Use the toggle in the Push Notification settings to indicate whether you want to request users share their location with OneSignal.
  5. 5.
    The remainder of this document will assist you with:

Create a OneSignal Account

  1. 1.
    Go to OneSignal.
  2. 2.
    Click Sign Up.
  3. 3.
    Create your account and complete the OneSignal onboarding.

Create a OneSignal App

  1. 1.
    If you didn't create an app as part of the OneSignal onboarding, navigate to your OneSignal dashboard and click + New App/Website.
    If you intend to send push notifications to your app's users on Android and iOS you will need to create a new app in OneSignal for each, Android and iOS.
  2. 2.
    Enter your app name. We recommend including the platform in your app name, for example, Employee Directory - Android or Employee Directory - iOS.
  3. 3.
    Select Apple iOS (APNs) or Google Android (FCM).
  4. 4.
    Click Next: Configure Your Platform.
  5. 5.
    Follow the platform-specific configuration instructions below.

Android Configuration

  1. 1.
    If you don't already have one, create a Firebase account. Instructions for getting started with Firebase are available here: Firebase Account Setup.
  2. 2.
    Follow OneSignal's instructions to generate a Firebase Server API key for sending Android App Notifications here: Android: Firebase Credentials.
  3. 3.
    In OneSignal, select Native Android as your target SDK.
  4. 4.
    Click Save & Continue.
  5. 5.
    Copy Your App ID.
  6. 6.
    Return to the Blocks tab of your Thunkable project. Do not close the OneSignal tab.
  7. 7.
    Click the gear icon next to Push Notification.
  8. 8.
    In the Android App ID field, paste Your App ID that you copied from OneSignal in step 5.
  9. 9.
    Indicate whether you want to collect Geolocation Permissions. OneSignal allows you to push messages to users based on their location. In order to do that, you need permission from your users to register their location. Use the toggle in the Push Notification settings to indicate whether you want to request users share their location with OneSignal.
    If you enable Geolocation Permissions, when you publish your app, ensure that you indicate that you're tracking location when you publish your app.
  10. 10.
    Click Submit.
  11. 11.
    Click the Live Test on Device icon and open the Thunkable Live app on your device.
  12. 12.
    Return to your OneSignal tab.
  13. 13.
    Click Check Subscribed Users.
  14. 14.
    If the configuration was successful, you will see a congratulations message.
  15. 15.
    Click Done.

Android Testing

To test Android push notifications, download the app to your Android device and send a test message through OneSignal to see the push notification in action.

iOS Configuration

Generate a p8 Certificate

  1. 1.
    Follow OneSignal's instructions to generate a p8 certificate: iOS: p8 Token-Based Connection to APNs.
  2. 2.
    When you get to the section titled "Provisioning Profiles," return to these instructions.

Add Push Notifications to the App Identifier

  1. 1.
    In your Apple Developer account, select Identifiers under the Certificates, IDs & Profiles heading.
  2. 2.
    Select your app from the list of Identifiers.
  3. 3.
    Scroll down the list of app capabilities, and place a checkmark next to Push Notifications.
  4. 4.
    Click Save.
  5. 5.
    Select your app from the list of Identifiers again.
  6. 6.
    Scroll down the list of app capabilities, until you get to Push Notifications again.
  7. 7.
    Click the associated Configure button.
  8. 8.
    Under Production SSL Certificate, click Create Certificate.
  9. 9.
    Under Upload a Certificate Signing Request, click Choose File.
  10. 10.
    Select the Certificate Signing Request (CSR) you downloaded from Thunkable as part of the publishing process.
  11. 11.
    Click Continue.
  12. 12.
    Click Download to download your iOS certificate.

Download your Provisioning Profile

  1. 1.
    Access your Apple Developer account’s Profiles.
  2. 2.
    Select your app from the list of Profiles.
  3. 3.
    Click Edit.
  4. 4.
    Click Save.
  5. 5.
    Click Download.

OneSignal

  1. 1.
    In OneSignal, select Native iOS as your target SDK.
  2. 2.
    Click Save & Continue.
  3. 3.
    Copy Your App ID.
  4. 4.
    Return to the Blocks tab of your Thunkable project. Do not close the OneSignal tab.
  5. 5.
    Click the gear icon next to Push Notification.
  6. 6.
    In the iOS App ID field, paste Your App ID that you copied from OneSignal in step 4.
  7. 7.
    Indicate whether you want to collect Geolocation Permissions. OneSignal allows you to push messages to users based on their location. In order to do that, you need permission from your users to register their location. Use the toggle in the Push Notification settings to indicate whether you want to request users share their location with OneSignal.
    If you enable Geolocation Permissions, when you publish your app, ensure that you indicate that you're tracking location when you publish your app.
  8. 8.
    Click Submit.

Generate a Provisioning Profile

You require a new provisioning profile with push notifications enabled to publish to the App Store. See OneSignal's instructions here: Generate a Provisioning Profile.

iOS Testing

To test iOS push notifications, you have to publish to TestFlight. This requires the provisioning profile with push notifications enabled.

Send Push Notifications

Once you have your platforms configured in OneSignal you can create and sent push notifications to your app's users. Follow OneSignal's instructions here: Sending Messages.

Blocks

User ID

The first time your app is opened on a new device, it is automatically assigned a unique push notification user ID. This block returns the user's push notification user ID that can be used to send a notification to a specific user with a web API call.