Integrations for Unity 3D

In our previous blog post, we examined how advertising integrations were made in the Unity 3D application. In this article, we will focus on other Unity 3D integrations.

1. Firebase Cloud Messaging Integration for Unity

To access the source I used while writing the article Click here.

Step 1: Create a Firebase project.

  • Before adding Firebase to your Unity project, you need to create a Firebase project to connect to your Unity project.
  • Go to Firebase Console, press the add project button and enter the name of your project. Add Google Analytics and create the project.

Step 2: Register your app with Firebase.

  • You can register one or more apps or games to connect to your Firebase project. If you're publishing your game on both IOS and Android, save both build targets of your Unity project with the same Firebase project. If you have multiple build variants with different IOS package IDs or Android app IDs defined, you must save each variant in the same Firebase project.
  • Go to Firebase Console. Then click on the Unity icon in the middle of the project overview page. If you've already added an app to your Firebase project, click Add App to view platform options. Choose which build target you want to save your Unity project in, or you can even choose to save both targets at the same time. Enter the platform-specific IDs of your Unity project. Click Save Application.

Step 3: Add Firebase configuration files.

● For iOS — Click Download GoogleService-Info.plist.

● For Android — click Download google-services.json.

● Open the Project window of your Unity project, then move your configuration files to the Assets Folder.

● Click the Next button in the Firebase console.

Step 4: Add Firebase SDK

  • In the Firebase console, click Download Firebase Unity SDK, then open the SDK in a convenient location.
  • In your open Unity project, go to Assets>Import Package>Custom Package.
  • From the zipped SDK, select the supported Firebase products you want to use in your app.
  • For optimal experience with Firebase Cloud Messaging, I recommend enabling Google Analytics in your project. You also need to add the Firebase for Analytics package to your app as part of the Analytics setup.

● Add the Firebase Cloud Messaging package: FirebaseMessaging.unitypackage

● Add the Firebase package for Google Analytics: FirebaseAnalytics.unitypackage

Step 5: Add user notifications frame.

• Click on the project in Xcode, then select the General tab from the Editor area.

• At the bottom of the page, scroll to Linked Meshes and Libraries, then click +: To Add a Frame.

• When it appears, go to UserNotifications.framework in that window, click on its entry, and then click on the Add button.

Step 6: Enable push notifications.

• Click on the project in Xcode, then select the Capabilities tab from the Editor area.

• Push the Switch to On for Notifications.

• Scroll to Background Modes, then switch to On.

• Select the Remote Notifications check box under Background Modes.

Step 7: Start Firebase Cloud Messaging.

  • The Firebase Cloud Message library will be initialized when adding handlers for either TokenReceived or MessageReceive.
  • Upon initialization, you are prompted for a registration token for the client application instance. The application receives the token with the OnTokenReceived event, which should be cached for later use. You will need this token if you want to target this specific device for messages.
  • Additionally, you will need to sign up for the OnMessageReceived event if you want to be able to receive incoming messages.
  • The whole setup looks like this:

2. Firebase Crashlytics Integration for Unity

To access the source I used while writing the article Click here.

Under this heading, I will explain how to install Firebase Crashlytics in your application with the Firebase Crashlytics SDK. This way, you can get comprehensive crash reports in the Firebase console.

Assuming that you have completed the project adding phase that I explained above for Cloud Messaging, I will skip that phase.

  1. My name: Install Crashlytics in the Firebase console.

• Click Crashlytics in the navigation panel on the left side of the Firebase console.

• If you have more than one app saved in your Firebase project, select the app you added from the drop-down menu next to Crashlytics in the top bar of the console.

• Click Enable Crashlytics.

Step 2: Add Firebase Crashlytics to your app.

• Download the Firebase Unity SDK, then unzip the SDK in a convenient location. Firebase Unity SDK is not platform specific.

• In your open Unity project, go to Assets>Import Package>Custom Package.

• Choose to import Crashlytics SDK (FirebaseCrashlytics.unitypackage) from Zip SDK.

• You can also import any other supported Firebase product.

Step 3: Start Crashlytics.

• Create a new C # script, then add a GameObject in the scene to the script.

• Open your first scene, then create an empty GameObjects “CrashlyticsInitializer”.

• Click Add Component from the Inspector for the new object.

• Select your script to add CrashlyticsInit to the CrashlyticsInitializer object.

3. Unity Remote Config Integration for Unity

First of all, in order to use Unity Remote Config, you need to install the Remote Config Package into the project. You can use Unity Package Manager for this. Follow Window > Package Manager.

After installing the Remote Config Package to your project, you need to check whether you are connected to Unity Service. You cannot use Remote Config without being connected to Unity. For Service control, you can click the Services panel next to the Inspector panel. If the tabs in the image below appear in the window that opens, you are connected to the Unity service. If not, you must Log In via Unity Hub.

If you cannot see the Remote Config panel. You can see the panel by following Window > Remote Config.

Below you see the Remote Config panel. First you need to create an Environment. You can create this by clicking the Create button. Next, on the left comes Settings Config Default. Each Settings contains 3 types of variables. Key, Type, Value. You can add new settings by clicking the Add Settings button. For example, you see enemySpeed Settings. Let's say you had previously set the enemySpeed value to 10. You built the game, published it, and then realized that 10 was too much. When you change the value of 10 to 0.01 directly via Remote Config instead of releasing a new version again, Build will automatically update itself and reduce the enemySpeed value to 0.01. You may be wondering how to change it. Just as you can change Remote Config settings within the Unity Editor, you can also change your settings through the Dashboard that Unity reserves for Remote Config. The second image below shows the Dashboard that can be accessed via web browser. Now let's see how to merge with code;

3.1. Remote Config Code Integration

As you can see in the screenshots, we call the Speed value in the Awake method via Remote Config. Thus, Speed now remains at the value given via Remote Config. In fact, using Remote Config is that simple.

I hope I could help. Enjoy your work.