@@ -34,6 +34,7 @@ for arg in "$@"; do
3434 case " $arg " in
3535 --platform=* ) PLATFORM=" ${arg# --platform=} " ;;
3636 --sdk=* ) SDK_TYPE=" ${arg# --sdk=} " ;;
37+ --device=* ) DEVICE=" ${arg# --device=} " ;;
3738 --skip) SKIP_BUILD=true; SKIP_DEVICE=true; SKIP_RESET=true ;;
3839 --skip-build) SKIP_BUILD=true ;;
3940 --skip-device) SKIP_DEVICE=true ;;
@@ -52,6 +53,7 @@ via flags or env vars.
5253Options:
5354 --platform=P ios | android
5455 --sdk=S flutter | react-native
56+ --device=NAME Device/simulator/AVD name (default: iPhone 17 / Google Pixel 8)
5557 --skip Skip build, device launch, and app reset (rerun tests only)
5658 --skip-build Skip app build (reuse existing)
5759 --skip-device Skip simulator/emulator launch
@@ -64,9 +66,7 @@ Env vars (set in .env or export):
6466 BUNDLE_ID Bundle/package id (default: com.onesignal.example)
6567 ONESIGNAL_APP_ID OneSignal app ID (written to demo app .env)
6668 ONESIGNAL_API_KEY OneSignal REST API key (written to demo app .env)
67- DEVICE Device name for wdio (default: iPhone 17 / Google Pixel 8)
6869 OS_VERSION Platform version (default: 26.2 / 14)
69- AVD_NAME Android AVD to boot (default: Pixel_8)
7070 IOS_SIMULATOR iOS simulator name (default: iPhone 17)
7171 IOS_RUNTIME simctl runtime id (default: iOS-26-2)
7272 APPIUM_PORT Appium port (default: 4723)
@@ -114,7 +114,6 @@ case "$PLATFORM" in
114114 * ) error " PLATFORM must be 'ios' or 'android', got '$PLATFORM '" ;;
115115esac
116116
117- [[ " $PLATFORM " == " android" ]] && error " Android is not supported yet. Only iOS is available for now."
118117[[ " $SDK_TYPE " != " flutter" ]] && error " Only flutter is supported for now. Got '$SDK_TYPE '."
119118
120119BUNDLE_ID=" ${BUNDLE_ID:- com.onesignal.example} "
@@ -123,7 +122,11 @@ if [[ "$SDK_TYPE" == "flutter" ]]; then
123122 FLUTTER_DIR=" ${FLUTTER_DIR:- $SDK_ROOT / OneSignal-Flutter-SDK} "
124123 [[ -d " $FLUTTER_DIR " ]] || error " Flutter SDK not found at $FLUTTER_DIR — set FLUTTER_DIR in .env"
125124 DEMO_DIR=" $FLUTTER_DIR /examples/demo"
126- APP_PATH=" ${APP_PATH:- $DEMO_DIR / build/ ios/ iphonesimulator/ Runner.app} "
125+ if [[ " $PLATFORM " == " ios" ]]; then
126+ APP_PATH=" ${APP_PATH:- $DEMO_DIR / build/ ios/ iphonesimulator/ Runner.app} "
127+ else
128+ APP_PATH=" ${APP_PATH:- $DEMO_DIR / build/ app/ outputs/ flutter-apk/ app-debug.apk} "
129+ fi
127130fi
128131
129132# ── Platform defaults ────────────────────────────────────────────────────────
@@ -135,7 +138,7 @@ if [[ "$PLATFORM" == "ios" ]]; then
135138else
136139 DEVICE=" ${DEVICE:- Google Pixel 8} "
137140 OS_VERSION=" ${OS_VERSION:- 14} "
138- AVD_NAME=" ${AVD_NAME:- Pixel_8 } "
141+ AVD_NAME=" ${AVD_NAME:- ${DEVICE // / _} } "
139142fi
140143
141144# ── 1. Build app ─────────────────────────────────────────────────────────────
164167 info " App built: $APP_PATH "
165168}
166169
170+ build_flutter_android () {
171+ if [[ -n " ${ONESIGNAL_APP_ID:- } " && -n " ${ONESIGNAL_API_KEY:- } " ]]; then
172+ info " Writing .env for demo app..."
173+ cat > " $DEMO_DIR /.env" << EOF
174+ ONESIGNAL_APP_ID=$ONESIGNAL_APP_ID
175+ ONESIGNAL_API_KEY=$ONESIGNAL_API_KEY
176+ E2E_MODE=true
177+ EOF
178+ else
179+ warn " ONESIGNAL_APP_ID / ONESIGNAL_API_KEY not set — skipping demo .env"
180+ fi
181+
182+ info " Installing Flutter dependencies..."
183+ (cd " $FLUTTER_DIR " && flutter pub get)
184+
185+ info " Building debug APK (this may take a few minutes)..."
186+ (cd " $DEMO_DIR " && flutter build apk --debug)
187+
188+ [[ -f " $APP_PATH " ]] || error " .apk not found after build at $APP_PATH "
189+ info " App built: $APP_PATH "
190+ }
191+
167192build_app () {
168193 if [[ " $SKIP_BUILD " == true ]]; then
169194 if [[ " $PLATFORM " == " ios" && ! -d " $APP_PATH " ]] || [[ " $PLATFORM " == " android" && ! -f " $APP_PATH " ]]; then
@@ -173,7 +198,11 @@ build_app() {
173198 return
174199 fi
175200
176- build_flutter_ios
201+ if [[ " $PLATFORM " == " ios" ]]; then
202+ build_flutter_ios
203+ else
204+ build_flutter_android
205+ fi
177206}
178207
179208# ── 2. Start device ──────────────────────────────────────────────────────────
0 commit comments