A React Native module for Urban Airship's iOS and Android SDK.
We accept pull requests! If you would like to submit a pull request, please fill out and submit a Code Contribution Agreement.
Please visit https://support.urbanairship.com/ for any issues integrating or using this module.
- React Native >= 0.44.0
- React Native cli >= 2.0.1
- Install and link the module:
react-native install urbanairship-react-native
react-native link urbanairship-react-native
-
Install cocoapods
-
Update the app's Podfile to include the Urban Airship SDK:
pod 'UrbanAirship-iOS-SDK'
- Update your pods:
pod install
- Open your apps project in the generated
.xcworkspace
file, add the following capabilities:
- Push Notification
- Background Modes > Remote Notifications
- Create a plist
AirshipConfig.plist
and include it in your application’s target:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>developmentAppKey</key>
<string>Your Development App Key</string>
<key>developmentAppSecret</key>
<string>Your Development App Secret</string>
<key>productionAppKey</key>
<string>Your Production App Key</string>
<key>productionAppSecret</key>
<string>Your Production App Secret</string>
</dict>
</plist>
- Optional. In order to take advantage of iOS 10 notification attachments, such as images, animated gifs, and video, you will need to create a notification service extension by following the iOS Notification Service Extension Guide
- Install and link the module:
react-native install urbanairship-react-native
react-native link urbanairship-react-native
- Create the
airshipconfig.properties
file in the applicationsmain/assets
:
developmentAppKey = Your Development App Key
developmentAppSecret = Your Development App Secret
productionAppKey = Your Production App Key
productionAppSecret = Your Production Secret
# FCM/GCM Sender ID
gcmSender = Your Google API Project Number
# Notification customization
notificationIcon = ic_notification
notificationAccentColor = #ff0000
Notifications by default are disabled to avoid prompting the user for permissions at an inopportune time. For testing purposes, you probably want to enable Notifications immediately to verify push is working:
import {
UrbanAirship,
UACustomEvent,
} from 'urbanairship-react-native'
...
export default class Sample extends Component {
constructor(props) {
super(props);
UrbanAirship.setUserNotificationsEnabled(true);
}
...
}