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

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"
      }
    }
  ]
]

Known Issues

  • Expo SDK 50+ (Dev Builds): Tapping a foreground notification may cause the app to reload when running in a dev client. This can be resolved by setting the launchMode to launcher in your app.json for expo-dev-client. See issue #550 for more details.
    "plugins": [
      [
        "expo-dev-client",
        {
          "ios": { "launchMode": "launcher" },
          "android": { "launchMode": "launcher" }
        }
      ]
    ]
    

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