Skip to content

OneSignalDevelopers/onesignal-supabase-sample-integration-app

Repository files navigation

OneSignal

Quickstart   •   Website   •   Docs   •   Examples

OneSignal + Supabase Sample Integration App

OneSignal makes engaging customers simple and is the fastest, most reliable service to send push notifications, in-app messages, SMS, and emails.

This repo contains the companion app to the Onesignal + Supabase Sample Integration guide.

🚦 Getting Started

  1. Run cp .env.example .env.local to duplicate the environment file template and set their values based on what you setup in the integration guide.
  2. If you're building for iOS, update the app's bundle and group IDs with the identifier you setup in Apple Developer Network runner nse

Your project diff should look similar to this 👇 after the changes.

diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 2864eb6..62cf60e 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -494,7 +494,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				PRODUCT_BUNDLE_IDENTIFIER = "com.onesignal.devrel.supabase-sample-integration";
+				PRODUCT_BUNDLE_IDENTIFIER = your.bundle.id;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
 				SWIFT_VERSION = 5.0;
@@ -738,7 +738,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				PRODUCT_BUNDLE_IDENTIFIER = "com.onesignal.devrel.supabase-sample-integration";
+				PRODUCT_BUNDLE_IDENTIFIER = your.bundle.id;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -765,7 +765,7 @@
 					"$(inherited)",
 					"@executable_path/Frameworks",
 				);
-				PRODUCT_BUNDLE_IDENTIFIER = "com.onesignal.devrel.supabase-sample-integration";
+				PRODUCT_BUNDLE_IDENTIFIER = your.bundle.id;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
 				SWIFT_VERSION = 5.0;
diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements
index ad08247..903def2 100644
--- a/ios/Runner/Runner.entitlements
+++ b/ios/Runner/Runner.entitlements
@@ -4,9 +4,5 @@
 <dict>
 	<key>aps-environment</key>
 	<string>development</string>
+	<key>com.apple.security.application-groups</key>
+	<array>
+		<string>group.your.app.group</string>
+	</array>
 </dict>
 </plist>
  1. Run flutter start to launch the app on your iOS device or emulator (iOS Simulator doesn't support push notifications).

👀 Looking For a Getting Started With Flutter Guide?

YT Thumb

We have other guides to help get your started

How it works

Todo: graphic

Setting External User ID

The EUID is when the user signs up or logs in.

final authResponse =
await Supabase.instance.client.auth.signInWithPassword(
email: email,
password: password,
);
final id = authResponse.user?.id;
if (id != null) {
OneSignal.shared.setExternalUserId(id);
}

Triggering an In-App Message

Prompt user for notification consent upon completing purchase with an in-app message.

final deviceState = await OneSignal.shared.getDeviceState();
final subscribed = deviceState?.subscribed;
if (subscribed == false) {
OneSignal.shared.addTrigger("prompt_notification", "true");
}


❤️ Developer Community

For additional resources, please join the OneSignal Developer Community.

Get in touch with us or learn more about OneSignal through the channels below.

Show your support

Give a ⭐️ if this project helped you, and watch this repo to stay up to date.