react-native-module

Introduction: React Native module for Urban Airship
More: Author   ReportBugs   
Tags:

npm version License: Apache 2.0

The official Airship React Native module for iOS and Android.

Features

  • Push Notifications - Rich, interactive push notifications with deep linking
  • Live Activities & Live Updates - Real-time content updates on iOS Lock Screen and Android Live Content
  • In-App Experiences - Contextual messaging, automation, and Scenes
  • Embedded Content - Render Airship Scenes directly in your React Native app
  • Custom Views - Extend Scenes with native content
  • Message Center - Persistent inbox for rich messages with HTML, video, and interactive content
  • Preference Center - User preference management
  • Feature Flags - Dynamic feature toggles and experimentation
  • Analytics - Comprehensive user behavior tracking
  • Contacts - User identification and contact management
  • Tags, Attributes & Subscription Lists - User segmentation, personalization, and subscription management
  • Privacy Controls - Granular data collection and feature management
  • Extensible & Hybrid Compatible - Works seamlessly in hybrid apps and supports native extensions

Quick Start

Standard React Native

Install the package:

npm install @ua/react-native-airship --save

or

yarn add @ua/react-native-airship

See iOS Integration below for the required Podfile setup.

Expo

Apps using Expo can use the airship-expo-plugin to configure the project. You will need to use expo prebuild (custom dev client) or eas build since this package contains native code.

First, install the plugin and the main package:

expo install airship-expo-plugin
yarn add @ua/react-native-airship

Then, add the plugin to your app.json:

"plugins": [
  [
    "airship-expo-plugin",
    {
      "android": {
        "icon": "./path/to/ic_notification.png"
      },
      "ios": {
        "mode": "development"
      }
    }
  ]
]

iOS Integration

This package supports two iOS dependency managers:

  • CocoaPods (default). The Airship SDK is pulled in through React Native's CocoaPods+SPM bridge (spm_dependency in react-native-airship.podspec) as an automatic-type Swift package product. Statically linking an automatic-type package lets every pod that embeds it carry its own copy, which collides at link time as duplicate-symbol errors, so your ios/Podfile needs:

    use_frameworks! :linkage => :dynamic
    
  • Swift Package Manager (experimental). React Native 0.87 adds an experimental, opt-in SwiftPM integration as an alternative to CocoaPods. This package ships a Package.swift, so it is picked up automatically once your app is set up for SwiftPM:

    cd ios
    npx react-native spm
    

    React Native's SwiftPM support is still marked experimental. On React Native <0.88, the generated autolinking package hardcodes an iOS 15 minimum, which prevents packages that require iOS 16 (including this one) from resolving. React Native 0.88 fixes this by reading the floor from your app's own Xcode deployment target instead.

Initialization

Initialize Airship in your App.tsx:

import { useEffect } from 'react';
import Airship from '@ua/react-native-airship';

export default function App() {
  useEffect(() => {
    const takeOff = async () => {
      try {
        await Airship.takeOff({
          default: {
            appKey: "YOUR_APP_KEY",
            appSecret: "YOUR_APP_SECRET"
          },
        });
        
        await Airship.push.enableUserNotifications();
      } catch (error) {
        console.error("Failed to take off:", error);
      }
    };

    takeOff();
  }, []);

  // ... your app code
}

For a more detailed setup guide, please see the full Getting Started Documentation.

Versions and Support

For the current Support Status of each module major, EOL dates, and the full lifecycle policy, see the Airship SDK Support Policy.

Resources

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools
AI Daily Digest