Quick Start
Install Capacitor plugin 0.2.0 and configure native startup.
Install the SDK
Install the GitHub release tag, then synchronize native dependencies:
npm install github:Stay22/stay22-capacitor-sdk#0.2.0
npx cap syncThe package is not published to npm. Set minSdkVersion to 24 or higher in android/variables.gradle. Set platform :ios, '15.0' in ios/App/Podfile and the app target's iOS Deployment Target to 15.0 in Xcode. Run npx cap sync ios after changing the iOS target.
Add the Maven repository to the host's top-level android/build.gradle:
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://raw.githubusercontent.com/Stay22/stay22-android-sdk/main/maven' }
}
}If your project keeps repositories in settings.gradle under dependencyResolutionManagement, add the same URL there instead. A template using FAIL_ON_PROJECT_REPOS rejects the allprojects form.
Initialize at app launch
Declare your partner ID natively so the plugin starts the SDK while Capacitor sets up its bridge, before JavaScript runs. This allows an iOS notification tap that cold-starts the app to reach Stay22.
ios/App/App/Info.plist
<key>Stay22PartnerAID</key>
<string>your-partner-id</string>android/app/src/main/AndroidManifest.xml, inside <application>:
<meta-data android:name="com.stay22.sdk.PartnerAID" android:value="your-partner-id" />For a native-first affirmative-consent guard, add these entries alongside the partner ID:
ios/App/App/Info.plist
<key>Stay22RequiresConsent</key>
<true/>Android manifest, inside <application>:
<meta-data android:name="com.stay22.sdk.RequiresConsent" android:value="true" />With those keys, startup requests and scheduling wait for an explicit Stay22.setEnabled({ enabled: true }). A value saved before the native 1.4.0 upgrade does not count as affirmative consent. A choice explicitly recorded on 1.4.0 or later remains stored. Pass the current choice on every app launch and whenever it changes.
Use await Stay22.initialize({ aid: 'your-partner-id' }) only when the ID is known at runtime and not declared natively. On Android that call may miss the first Activity resume. On iOS, JavaScript starts after a launch-time notification tap may already have been delivered.
Consent and notification permission
import { Stay22 } from '@stay22/capacitor';
await Stay22.setEnabled({ enabled: userHasOptedInToStay22Offers });
const { value: granted } = await Stay22.requestNotificationPermission();setEnabled controls Stay22 offers; notification permission is the operating system's separate gate. Check permission later with await Stay22.hasNotificationPermission(). An existing denial or disabled notification channel may require the user to change system settings.
Tell the SDK about the trip
await Stay22.setTravelContext({
address: 'Paris, France',
checkinDate: '2027-03-20',
checkoutDate: '2027-03-25',
});Use YYYY-MM-DD dates and supply at least an address, hotel name, or both coordinates. Other fields are latitude, longitude, hotelName, adults, and children. Omitted fields can retain values from the prior trip; clear context before an unrelated one.
Platform setup notes
Add the URL schemes the SDK checks to ios/App/App/Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>airbnb</string>
<string>booking</string>
<string>expda</string>
<string>hotelsapp</string>
<string>agoda</string>
</array>An undeclared scheme is reported as not installed. Android merges the corresponding declarations from the native SDK manifest.
Check iOS notification routing if your app already uses local notifications or owns the notification delegate. Use test mode to check delivery and tapping before shipping.