Getting Started

This is a developers' guide for setting up the Airship SDK for Unity apps.

The Airship Unity Plugin allows a developer to integrate push notification services with Unity apps targeting both Android and iOS. This plugin is designed to be cross-platform, and applications making use of it can leverage the same code on both platforms.

Resources

Requirements

  • Unity 5+
  • iOS: Xcode 10+
  • Android: Android SDK installed and updated (requires Android MinSdkVersion = 16)
  • Android: Using Android SDK manager, install 28+. If Custom Gradle Template is used, the gradle template needs to be configured to use API VERSION 28+.

Setup

Download the latest plugin and import the unitypackage into the unity project: Open Assets -> Import Package -> Custom Package.

Configure Airship Settings: Open Window -> Airship -> Settings and set the Airship settings.

 Important

Leave the the field for Android FCM Sender ID BLANK for both Production and Development.

After generating a project for iOS, enable Push Notifications in the project editor's Capabilities pane:

After adding the Push Notifications capability, download the Android Firebase configuration file google-services.json from the application's Firebase console into the Assets directory.

If your Unity application does not have an associated application in the Firebase console, follow the FCM setup instructions to set one up.

If proguard is enabled, add Airship settings to the proguard-user.txt file.

-keep public class com.urbanairship.unityplugin.UnityPlugin -keepclassmembers class com.urbanairship.unityplugin.UnityPlugin { public ; public ; static ; }

Notification Service Extension

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.

Send Your First Push Notification

At this point in the guide, if you followed all the steps above you should be ready to send a test push notification to verify everything is set up properly.

Before sending a push, you must enable user notifications. The module does not enable user notifications by default in order to avoid prompting the user for permissions. But for a testing purposes, you can enable user notifications as soon as the application is ready. You may also want to set default foreground presentation options to display the notification in the foreground on iOS 10. On older iOS devices, make sure you background the app before sending the push.

Enable user notifications
UAirship.Shared.UserNotificationsEnabled = true;