Skip to main content

iOS Firebase Cloud Messaging Integration in Unity3D

✍ Last Updated : January 2, 2023

🚪 Prequisite Knowledge (Optional)

Describe Initial Knowledge that reader need to know before reading this article

  1. Firebase
  2. Unity3D

❓ Key Question / Problem / Issue

Describe what question / Problem / Issue this knowledge should answer

How to integrate Firebase Cloud Messaging in Unity iOS Builds ?

✅ Expected Output/Definition of Done

Define what information you really need and the definition of done

Firebase Cloud Messaging fully work in iOS Game Builds

🎁 Resulting Solution

Write writing results below

Requirement:

  1. Create new project in Firebase
  2. Add Firebase Messaging packages to Unity
  3. Install cocoapods in Xcode project root folder

Step 1: Add iOS app to firebase

  1. Open Firebase console, in Project Overview press setting icon -> Project settings.

    UntitledUntitled

  2. In General -> Your apps, press Add app.

    UntitledUntitled

  3. Press the IOS+ icon for iOS app.

    UntitledUntitled

  4. In Apple Bundle Id, insert your bundle Id project (it’s recommend to use the same bundle Id name as in your Android app build), after register your app, follow the rest of the instruction given by Firebase.

    UntitledUntitled

  5. In Project setting → Cloud Messaging → Apple App Configuration, in APNs Authentication Key press Upload.

    UntitledUntitled

  6. Insert your APNs auth key, Key ID and Team Id (you can create and download it on https://developer.apple.com/account in Certificates, Identifiers & Profiles section. Or ask Tech Department for APNs auth key). After you input all the required data, press Upload.

    UntitledUntitled

Step 2: Add Firebase packages to Xcode project

  1. Please follow the setting build section in this page ‣

  2. In TARGETS → Unity-iPhone → General → Frameworks, Libraries, and Embedded Content, check if FirebaseMessaging exist, if exist please skip to step 6 , if not please follow the next step.

    Screenshot 2023-01-02 at 13.25.03.pngScreenshot 2023-01-02 at 13.25.03.png

  3. In File, select Add Packages.

    Screenshot 2023-01-02 at 13.28.29.pngScreenshot 2023-01-02 at 13.28.29.png

  4. Search firebase-ios-sdk in search bar, or insert the repository URL for Firebase (https://github.com/firebase/firebase-ios-sdk). Next in Add to Project section, select Unity-iPhone, select Add Packages in bottom right corner.

    Screenshot 2023-01-02 at 13.30.20.pngScreenshot 2023-01-02 at 13.30.20.png

  5. In list of Firebase packages, select FirebaseMessaging and select Add Package.

    Screenshot 2023-01-03 at 09.30.38.pngScreenshot 2023-01-03 at 09.30.38.png

  6. (Optional) If you encounter this error when uploading your archive to testflight, get back to your Xcode project.

    Screenshot 2022-12-28 at 09.56.46.pngScreenshot 2022-12-28 at 09.56.46.png

  7. In TARGETS → UnityFramework → Build Settings → Build Option, in “Always Embed Swift Standard Libraries” select No.

    Screenshot 2023-01-02 at 13.38.45.pngScreenshot 2023-01-02 at 13.38.45.png