Push Notifications for Supabase
Send push notifications to your React Native app, triggered by database events.
-
Create Entrig Account - Sign up at entrig.com
-
Connect Supabase - Authorize Entrig to access your Supabase project
How it works (click to expand)
During onboarding, you'll:
- Click the "Connect Supabase" button
- Sign in to your Supabase account (if not already signed in)
- Authorize Entrig to access your project
- Select which project to use (if you have multiple)
That's it! Entrig will automatically set up everything needed to send notifications. No manual SQL or configuration required.
-
Upload FCM Service Account (Android) - Upload Service Account JSON and provide your Application ID
How to get FCM Service Account JSON (click to expand)
- Create a Firebase project at console.firebase.google.com
- Add your Android app to the project
- Go to Project Settings → Service Accounts
- Click "Firebase Admin SDK"
- Click "Generate new private key"
- Download the JSON file
- Upload this file to the Entrig dashboard
What is Application ID? (click to expand)
The Application ID is your Android app's package name (e.g.,
com.example.myapp). You can find it in:- Your
android/app/build.gradlefile underapplicationId - Or in your
AndroidManifest.xmlunder thepackageattribute
-
Upload APNs Key (iOS) - Upload
.p8key file with Team ID, Bundle ID, and Key ID to EntrigHow to get APNs Authentication Key (click to expand)
- Enroll in Apple Developer Program
- Go to Certificates, Identifiers & Profiles
- Navigate to Keys → Click "+" to create a new key
- Enter a key name and enable "Apple Push Notifications service (APNs)"
- Click "Continue" then "Register"
- Download the
.p8key file (you can only download this once!) - Note your Key ID (shown on the confirmation page - 10 alphanumeric characters)
- Note your Team ID (found in Membership section of your Apple Developer account - 10 alphanumeric characters)
- Note your Bundle ID (found in your Xcode project settings or
Info.plist- reverse domain format likecom.example.app) - Upload the
.p8file along with Team ID, Bundle ID, and Key ID to the Entrig dashboard
Production vs Sandbox environments (click to expand)
Entrig supports configuring both APNs environments:
- Production: For App Store releases and TestFlight builds
- Sandbox: For development builds via Xcode
You can configure one or both environments during onboarding. Developers typically need Sandbox for testing and Production for live releases. You can use the same APNs key for both environments, but you'll need to provide the configuration separately for each.
npm install @entrig/react-nativeor
yarn add @entrig/react-nativeNo setup required for Android. We'll take care of it.
Run this command in your project root:
npx @entrig/react-native setup iosThis automatically configures:
- AppDelegate.swift with Entrig notification handlers
- Entitlements with push notification capabilities (creates the file if it doesn't exist)
- Info.plist with background modes
- project.pbxproj with CODE_SIGN_ENTITLEMENTS reference
Note: The command creates
.backupfiles for safety. You can delete them after verifying everything works.
Manual AppDelegate setup (click to expand)
- Open
ios/YourApp.xcworkspace - Select your target → Signing & Capabilities
- Click
+ Capability→ Push Notifications - Click
+ Capability→ Background Modes → EnableRemote notifications
Add import UserNotifications and import EntrigSDK, add UNUserNotificationCenterDelegate conformance, then add the notification methods.
RN 0.74+ (new style — UIResponder, UIApplicationDelegate)
import UIKit
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
import UserNotifications
import EntrigSDK
@main
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
var reactNativeDelegate: ReactNativeDelegate?
var reactNativeFactory: RCTReactNativeFactory?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
UNUserNotificationCenter.current().delegate = self
Entrig.checkLaunchNotification(launchOptions)
let delegate = ReactNativeDelegate()
let factory = RCTReactNativeFactory(delegate: delegate)
delegate.dependencyProvider = RCTAppDependencyProvider()
reactNativeDelegate = delegate
reactNativeFactory = factory
window = UIWindow(frame: UIScreen.main.bounds)
factory.startReactNative(withModuleName: "YourApp", in: window, launchOptions: launchOptions)
return true
}
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Entrig.didRegisterForRemoteNotifications(deviceToken: deviceToken)
}
func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error) {
Entrig.didFailToRegisterForRemoteNotifications(error: error)
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
Entrig.willPresentNotification(notification)
completionHandler(Entrig.getPresentationOptions())
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
Entrig.didReceiveNotification(response)
completionHandler()
}
}Replace
"YourApp"with your actual module name.
RN 0.71–0.73 (old style — RCTAppDelegate)
import UIKit
import UserNotifications
import EntrigSDK
@main
class AppDelegate: RCTAppDelegate, UNUserNotificationCenterDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
UNUserNotificationCenter.current().delegate = self
Entrig.checkLaunchNotification(launchOptions)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Entrig.didRegisterForRemoteNotifications(deviceToken: deviceToken)
super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
override func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error) {
Entrig.didFailToRegisterForRemoteNotifications(error: error)
super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
Entrig.willPresentNotification(notification)
completionHandler(Entrig.getPresentationOptions())
}
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
Entrig.didReceiveNotification(response)
completionHandler()
}
}Step 1: Configure your bundle identifier
Update your app.json with a proper bundle identifier (not the default Expo one):
{
"expo": {
"ios": {
"bundleIdentifier": "com.yourcompany.yourapp"
}
}
}Important: Don't use Expo's auto-generated bundle IDs (like
com.anonymous.*). Use your own reverse-domain identifier.
Step 2: Add the config plugin
Add the plugin to your app.json:
{
"expo": {
"plugins": ["@entrig/react-native"]
}
}Step 3: Run prebuild
npx expo prebuild
# or run directly (prebuild happens automatically)
npx expo run:ios
npx expo run:androidNote:
npx expo run:iosautomatically runsnpx expo prebuildif theios/folder doesn't exist. The plugin runs during prebuild and configures everything automatically.
The plugin automatically configures:
- ✅ AppDelegate with Entrig notification handlers (supports Expo SDK 54+)
- ✅ Info.plist with background modes (
UIBackgroundModes: ["remote-notification"]) - ✅ Entitlements with push capabilities (
aps-environment: development)
Step 4: Enable Push Notifications in Apple Developer Portal
- Go to Apple Developer Portal
- Select your Bundle ID (the one from your
app.json) - Enable "Push Notifications" capability
- Save
Step 5: Select your development team in Xcode
- Open
ios/YourApp.xcworkspacein Xcode - Select your project in the navigator
- Go to "Signing & Capabilities" tab
- Select your Team from the dropdown
- Xcode will automatically generate the provisioning profile with push notifications
Common error: If you see "Your provisioning profile doesn't support Push Notifications", make sure you completed Step 4 and Step 5.
Step 6: Verify configuration (Optional)
After prebuild, verify the plugin worked correctly:
-
Check AppDelegate (
ios/YourApp/AppDelegate.swift):- Should have
import EntrigSDKandimport UserNotifications - Should have
UNUserNotificationCenterDelegateconformance - Should have Entrig notification methods
- Should have
-
Check Info.plist (
ios/YourApp/Info.plist):<key>UIBackgroundModes</key> <array> <string>remote-notification</string> </array>
-
Check Entitlements (
ios/YourApp/YourApp.entitlements):<key>aps-environment</key> <string>development</string>
If the plugin didn't work (manual setup)
If any of the above are missing after prebuild, add them manually:
1. Update AppDelegate.swift
Add imports at the top:
import UserNotifications
import EntrigSDKAdd UNUserNotificationCenterDelegate to class declaration:
public class AppDelegate: ExpoAppDelegate, UNUserNotificationCenterDelegate {Add setup in didFinishLaunchingWithOptions (right after the function opens):
public override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
// Entrig: Setup push notification handling
UNUserNotificationCenter.current().delegate = self
Entrig.checkLaunchNotification(launchOptions)
// ... rest of existing code
}Add notification methods before the closing brace } of AppDelegate:
// MARK: - Entrig Push Notification Handling
public override func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
Entrig.didRegisterForRemoteNotifications(deviceToken: deviceToken)
super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
public override func application(
_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error
) {
Entrig.didFailToRegisterForRemoteNotifications(error: error)
super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
}
public func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
Entrig.willPresentNotification(notification)
completionHandler(Entrig.getPresentationOptions())
}
public func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
Entrig.didReceiveNotification(response)
completionHandler()
}2. Update Info.plist (ios/YourApp/Info.plist)
Add this before the closing </dict> tag:
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>3. Update Entitlements (ios/YourApp/YourApp.entitlements)
Replace the contents with:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>Note: Change
developmenttoproductionfor App Store releases.
Native Entrig module not found (iOS)
This means the EntrigReactNative pod was not installed. Run:
cd ios && pod installThen rebuild the app. If the error persists, verify EntrigReactNative appears in ios/Podfile.lock:
grep "EntrigReactNative" ios/Podfile.lockIf it's missing, make sure you are on @entrig/react-native version that includes the root-level EntrigReactNative.podspec and re-run pod install.
Push token not generated (iOS)
The device token won't be generated if the AppDelegate is not configured. Run the setup command:
npx @entrig/react-native setup iosThen rebuild. Also ensure:
- Push Notifications capability is added in Xcode (Target → Signing & Capabilities)
- You are testing on a real device (simulators cannot receive push notifications)
- The APNs key is uploaded to your Entrig dashboard
pod install CocoaPods dependency errors
Try cleaning and reinstalling:
cd ios
rm Podfile.lock
rm -rf Pods
pod deintegrate
pod repo update
pod installimport Entrig from '@entrig/react-native';
// Initialize Entrig (call once at app startup)
await Entrig.init({ apiKey: 'YOUR_ENTRIG_API_KEY' });How to get your Entrig API key (click to expand)
- Sign in to your Entrig account at entrig.com
- Go to your dashboard
- Navigate to your project settings
- Copy your API Key from the project settings page
- Use this API key in the
Entrig.init()call above
Automatic registration with Supabase Auth (Recommended - click to expand)
Listen to Supabase auth state changes and automatically register/unregister devices:
import { useEffect } from 'react';
import Entrig from '@entrig/react-native';
import { supabase } from './supabase'; // your Supabase client
function App() {
useEffect(() => {
const { data: { subscription } } = supabase.auth.onAuthStateChange(
async (event, session) => {
if (session?.user) {
// User signed in - register device
await Entrig.register(session.user.id);
} else {
// User signed out - unregister device
await Entrig.unregister();
}
}
);
return () => subscription.unsubscribe();
}, []);
return <YourApp />;
}Important: Devices are registered with the Supabase Auth user ID (
auth.users.id). When creating notifications, make sure the user identifier field you select contains this same Supabase Auth user ID to ensure notifications are delivered to the correct users.
Manual registration (click to expand)
Register device:
const { data: { user } } = await supabase.auth.getUser();
if (user) {
await Entrig.register(user.id);
}Unregister device:
await Entrig.unregister();Note:
register()automatically handles permission requests. TheuserIdyou pass here must match the user identifier field you select when creating notifications.
Custom permission handling (click to expand)
If you want to handle notification permissions yourself, disable automatic permission handling:
await Entrig.init({
apiKey: 'YOUR_ENTRIG_API_KEY',
handlePermission: false,
});Then request permissions manually before registering:
const granted = await Entrig.requestPermission();Using the useEntrigEvent hook (Recommended):
import { useEntrigEvent } from '@entrig/react-native';
function MyComponent() {
// Foreground notifications (when app is open)
useEntrigEvent('foreground', (event) => {
console.log('Notification received:', event.title, event.body);
});
// Notification tap (when user taps a notification)
useEntrigEvent('opened', (event) => {
// Navigate to specific screen based on event.data
console.log('Notification opened:', event.data);
});
return <YourComponent />;
}Using event listeners directly:
import Entrig from '@entrig/react-native';
// Foreground notifications
const subscription = Entrig.onForegroundNotification((event) => {
console.log('Foreground:', event.title, event.body);
});
// Notification tap
const subscription2 = Entrig.onNotificationOpened((event) => {
console.log('Opened:', event.data);
});
// Clean up when done
subscription.remove();
subscription2.remove();Get the notification that launched the app (cold start):
const notification = await Entrig.getInitialNotification();
if (notification) {
// App was launched from a notification tap
console.log('Launched from notification:', notification.data);
}NotificationEvent contains:
title- Notification titlebody- Notification body textdata- Custom payload data from your databaseisForeground- Whether the notification was received in the foreground
Learn how to create notification triggers in the dashboard (click to expand)
Create notification triggers in the Entrig dashboard. The notification creation form has two sections: configuring the trigger and composing the notification message.
Set up when and to whom notifications should be sent.
Choose the database table where events will trigger notifications (e.g., messages, orders). This is the "trigger table" that activates the notification.
Choose which database operation triggers the notification:
- INSERT - When new rows are created
- UPDATE - When existing rows are modified
- DELETE - When rows are deleted
Specify how to identify notification recipients. Toggle "Use join table" to switch between modes.
Important: The user identifier field you select here must contain the same user ID that was used when registering the device. This should be the Supabase Auth user ID (
auth.users.id).
Single User Mode (Default):
- Select a field that contains the user ID directly
- Supports foreign key navigation (e.g., navigate through
orders.customer_idto reachcustomers.user_id) - Example: For a
messagestable withuser_idfield, selectuser_id
Multi-User Mode (Join Table):
-
Use when one database event should notify multiple users
-
Requires configuring the relationship between tables:
Event Table Section:
- Lookup Field: Select a foreign key field that links to your join table
- Example: For notifying all room members when a message is sent, select
room_idfrom themessagestable
- Example: For notifying all room members when a message is sent, select
Join Table Section:
- Join Table: Select the table containing recipient records
- Example:
room_memberstable that links rooms to users
- Example:
- Matching Field: Field in the join table that matches your lookup field
- Usually auto-populated to match the lookup field name
- User ID Field: Field containing the actual user identifiers
- Supports foreign key navigation
- Should contain the same user ID used during device registration
- Lookup Field: Select a foreign key field that links to your join table
Filter when notifications are sent based on the trigger event data:
- Add conditions to control notification sending (e.g., only when
status = 'completed') - Supports multiple conditions with AND/OR logic
Filter which users receive the notification based on join table data:
- Example: Only notify users where
role = 'admin'in the join table
Design the notification content that users will see.
Select database fields to use as dynamic placeholders:
- Click "Add Fields" to open the field selector
- Selected fields appear as clickable pills (e.g.,
{{messages.content}}) - Click any pill to insert it at your cursor position in title or body
Write your notification text using placeholders:
- Use double-brace format:
{{table.column}} - Example Title:
New message from {{users.name}} - Example Body:
{{messages.content}} - Placeholders are replaced with actual data when notifications are sent
Single User Notification:
- Table:
orders, Event:INSERT - User ID:
customer_id - Title:
Order Confirmed! - Body:
Your order #{{orders.id}} has been received
Multi-User Notification (Group Chat):
- Table:
messages, Event:INSERT - Lookup Field:
room_id - Join Table:
room_members - Matching Field in Join Table:
room_id - User ID:
user_id - Title:
New message in {{rooms.name}} - Body:
{{users.name}}: {{messages.content}}
- Email: team@entrig.com