@@ -66,6 +66,8 @@ Env vars (set in .env or export):
6666 BUNDLE_ID Bundle/package id (default: com.onesignal.example)
6767 ONESIGNAL_APP_ID OneSignal app ID (written to demo app .env)
6868 ONESIGNAL_API_KEY OneSignal REST API key (written to demo app .env)
69+ FLUTTER_DIR Flutter SDK repo root (default: ../../OneSignal-Flutter-SDK)
70+ RN_DIR React Native SDK repo root (default: ../../react-native-onesignal)
6971 OS_VERSION Platform version (default: 26.2 / 16)
7072 IOS_SIMULATOR iOS simulator name (default: iPhone 17)
7173 IOS_RUNTIME simctl runtime id (default: iOS-26-2)
@@ -114,7 +116,10 @@ case "$PLATFORM" in
114116 * ) error " PLATFORM must be 'ios' or 'android', got '$PLATFORM '" ;;
115117esac
116118
117- [[ " $SDK_TYPE " != " flutter" ]] && error " Only flutter is supported for now. Got '$SDK_TYPE '."
119+ case " $SDK_TYPE " in
120+ flutter|react-native) ;;
121+ * ) error " SDK_TYPE must be 'flutter' or 'react-native', got '$SDK_TYPE '" ;;
122+ esac
118123
119124BUNDLE_ID=" ${BUNDLE_ID:- com.onesignal.example} "
120125
@@ -127,6 +132,15 @@ if [[ "$SDK_TYPE" == "flutter" ]]; then
127132 else
128133 APP_PATH=" ${APP_PATH:- $DEMO_DIR / build/ app/ outputs/ flutter-apk/ app-debug.apk} "
129134 fi
135+ elif [[ " $SDK_TYPE " == " react-native" ]]; then
136+ RN_DIR=" ${RN_DIR:- $SDK_ROOT / react-native-onesignal} "
137+ [[ -d " $RN_DIR " ]] || error " React Native SDK not found at $RN_DIR — set RN_DIR in .env"
138+ DEMO_DIR=" $RN_DIR /examples/demo"
139+ if [[ " $PLATFORM " == " ios" ]]; then
140+ APP_PATH=" ${APP_PATH:- $DEMO_DIR / ios/ build/ Build/ Products/ Debug-iphonesimulator/ demo.app} "
141+ else
142+ APP_PATH=" ${APP_PATH:- $DEMO_DIR / android/ app/ build/ outputs/ apk/ debug/ app-debug.apk} "
143+ fi
130144fi
131145
132146# ── Platform defaults ────────────────────────────────────────────────────────
189203 info " App built: $APP_PATH "
190204}
191205
206+ write_rn_demo_env () {
207+ if [[ -n " ${ONESIGNAL_APP_ID:- } " && -n " ${ONESIGNAL_API_KEY:- } " ]]; then
208+ info " Writing .env for demo app..."
209+ cat > " $DEMO_DIR /.env" << EOF
210+ ONESIGNAL_APP_ID=$ONESIGNAL_APP_ID
211+ ONESIGNAL_API_KEY=$ONESIGNAL_API_KEY
212+ E2E_MODE=true
213+ EOF
214+ else
215+ warn " ONESIGNAL_APP_ID / ONESIGNAL_API_KEY not set — skipping demo .env"
216+ fi
217+ }
218+
219+ setup_rn_sdk () {
220+ info " Building React Native SDK & packing tarball..."
221+ (cd " $RN_DIR " && bun run build)
222+ (cd " $RN_DIR " && rm -f react-native-onesignal* .tgz && bun pm pack && mv react-native-onesignal-* .tgz react-native-onesignal.tgz)
223+
224+ info " Installing demo dependencies..."
225+ (cd " $DEMO_DIR " && bun pm cache rm && bun remove react-native-onesignal && bun add file:../../react-native-onesignal.tgz)
226+ }
227+
228+ build_rn_ios () {
229+ write_rn_demo_env
230+ setup_rn_sdk
231+
232+ info " Installing CocoaPods..."
233+ (cd " $DEMO_DIR /ios" && pod install)
234+
235+ info " Building debug .app for simulator (this may take a few minutes)..."
236+ (cd " $DEMO_DIR /ios" && xcodebuild \
237+ -workspace demo.xcworkspace \
238+ -scheme demo \
239+ -configuration Debug \
240+ -sdk iphonesimulator \
241+ -derivedDataPath build \
242+ CODE_SIGN_IDENTITY=" " \
243+ CODE_SIGNING_REQUIRED=NO \
244+ CODE_SIGNING_ALLOWED=NO)
245+
246+ [[ -d " $APP_PATH " ]] || error " .app not found after build at $APP_PATH "
247+ info " App built: $APP_PATH "
248+ }
249+
250+ build_rn_android () {
251+ write_rn_demo_env
252+ setup_rn_sdk
253+
254+ info " Building debug APK (this may take a few minutes)..."
255+ (cd " $DEMO_DIR /android" && ./gradlew assembleDebug)
256+
257+ [[ -f " $APP_PATH " ]] || error " .apk not found after build at $APP_PATH "
258+ info " App built: $APP_PATH "
259+ }
260+
192261build_app () {
193262 if [[ " $SKIP_BUILD " == true ]]; then
194263 if [[ " $PLATFORM " == " ios" && ! -d " $APP_PATH " ]] || [[ " $PLATFORM " == " android" && ! -f " $APP_PATH " ]]; then
@@ -198,10 +267,18 @@ build_app() {
198267 return
199268 fi
200269
201- if [[ " $PLATFORM " == " ios" ]]; then
202- build_flutter_ios
203- else
204- build_flutter_android
270+ if [[ " $SDK_TYPE " == " flutter" ]]; then
271+ if [[ " $PLATFORM " == " ios" ]]; then
272+ build_flutter_ios
273+ else
274+ build_flutter_android
275+ fi
276+ elif [[ " $SDK_TYPE " == " react-native" ]]; then
277+ if [[ " $PLATFORM " == " ios" ]]; then
278+ build_rn_ios
279+ else
280+ build_rn_android
281+ fi
205282 fi
206283}
207284
0 commit comments