Flutter

Quick Start

Install Flutter package 1.6.0, configure native startup and submit a trip.

Install the SDK

Add the Git dependency to pubspec.yaml:

dependencies:
  stay22_flutter:
    git:
      url: https://github.com/Stay22/stay22-flutter-sdk.git
      ref: '1.6.0'

Run flutter pub get. The plugin bundles its iOS framework. Android needs Stay22's Maven repository in your app's top-level build file.

android/build.gradle.kts

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://raw.githubusercontent.com/Stay22/stay22-android-sdk/main/maven") }
    }
}

For a Groovy android/build.gradle, use maven { url 'https://raw.githubusercontent.com/Stay22/stay22-android-sdk/main/maven' } inside its repository block instead. Without that repository, Gradle cannot resolve com.stay22:sdk.

Initialize at app launch

Declare your partner ID natively so the SDK starts before Dart runs. This lets the iOS SDK receive a notification tap that cold-starts your app and lets the Android permission prompt find a live screen.

ios/Runner/Info.plist

<key>Stay22PartnerAID</key>
<string>your-partner-id</string>
<key>Stay22RequiresConsent</key>
<true/>

android/app/src/main/AndroidManifest.xml, inside <application>:

<meta-data android:name="com.stay22.sdk.PartnerAID" android:value="your-partner-id" />
<meta-data android:name="com.stay22.sdk.RequiresConsent" android:value="true" />

The consent-required entries above keep the SDK off until your app enables it. They require Flutter 1.4.0 or later. An enabled value stored before the native 1.4.0 upgrade is not an affirmative choice; an explicit choice made on 1.4.0 or later remains stored. Omit the consent-required entries only if your consent model permits Stay22 to run by default.

At each launch, pass the user's current choice before submitting a trip, and repeat the call when that choice changes:

import 'package:stay22_flutter/stay22_flutter.dart';

await Stay22.setEnabled(userHasOptedInToStay22Offers);

Use await Stay22.initialize(aid: 'your-partner-id') only if the ID is known at runtime and is not declared natively. Dart-only initialization cannot receive an iOS notification tap delivered before Dart starts.

Ask for notification permission

Ask when it fits your app's consent flow:

final granted = await Stay22.requestNotificationPermission();

Check permission later with await Stay22.hasNotificationPermission(). Android 12 and below do not show a runtime prompt; an existing denial or disabled notification channel may require the user to change system settings.

Tell the SDK about the trip

await Stay22.setTravelContext(TravelContext(
  address: 'Paris, France',
  checkinDate: '2027-03-20',
  checkoutDate: '2027-03-25',
));

Use YYYY-MM-DD dates. Supply at least an address, hotel name or both coordinates. Other available fields are latitude, longitude, hotelName, adults, and children.

The native SDK retains earlier fields when you omit them. For an unrelated trip, clear the context first. A change only to guest counts does not update this release's native context; clear it and send the full trip again. See context updates.

Platform setup notes

On iOS, add the schemes the SDK checks to ios/Runner/Info.plist:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>airbnb</string>
    <string>booking</string>
    <string>expda</string>
    <string>hotelsapp</string>
    <string>agoda</string>
</array>

An omitted scheme is reported as not installed. Android merges the equivalent declarations from the SDK manifest.

If another iOS notification library owns the delegate, it must forward Stay22 taps and foreground presentations exactly once. See notification callbacks.

Normal scheduling waits for your app to leave the foreground. Use test mode for a short development loop.

On this page