Unity Setup

How to install the Airship Unity plugin.

Requirements

  • Unity 5+
  • iOS: Xcode 15.3+
  • iOS: Minimum deployment target iOS 14+
  • Android: Android SDK installed and updated (requires minSdkVersion = 21+)
  • Android: Using Android SDK manager, install API 34+.
    • If a Custom Gradle Template is used, the gradle template needs to be configured to use API VERSION 34+.

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 Android FCM Sender ID field BLANK for both Production and Development.

 Important

If your app uses Airship’s EU cloud site, you will need to configure that using the Cloud Site setting.

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 and add it to 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

To take advantage of notification attachments, such as images, animated gifs, and video, you will need to create a notification service extension.

Follow the steps in the iOS Notification Service Extension Guide.

Implementation best practices

Make sure to set up logging. Internal logging can be valuable when troubleshooting issues that arise when testing.

Anytime you make any changes or updates to the SDK, test on a development device to ensure your integration was successful. Also make sure analytic information is still flowing to your Airship project before sending the app to production.

Troubleshooting

A common error when setting up our Unity plugin is “Could not create an instance of type org.gradle.initialization.DefaultSettings_Decorated”. If you encounter this error, take these steps in the Unity Editor:

  1. Go to Assets, then External Dependency Manager, then Android Resolver, then Force Resolve.

  2. Sometimes Unity has difficulty retrieving the JDK installed with your editor even when selected. To solve this:

    1. Go to Edit, then Preferences, then External Tools.
    2. For JDK, select Copy Path, uncheck JDK Installed with Unity (Recommended), then paste the path.
  3. If the previous steps do not fix your issue:

    1. Go to Project Settings, then Player, then Android, then Publishing Settings, then Build, and then select Custom Main Gradle Template and Custom Gradle Properties Template.

    2. Go to Assets, then External Dependency Manager, then Android Resolver, then Force Resolve.