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
- Firebase
- 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:
- Create new project in Firebase
- Add Firebase Messaging packages to Unity
- Install cocoapods in Xcode project root folder
Step 1: Add iOS app to firebase
-
Open Firebase console, in Project Overview press setting icon -> Project settings.
-
In General -> Your apps, press Add app.
-
Press the IOS+ icon for iOS app.
-
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.
-
In Project setting → Cloud Messaging → Apple App Configuration, in APNs Authentication Key press Upload.
-
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.
Step 2: Add Firebase packages to Xcode project
-
Please follow the setting build section in this page ‣
-
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.
-
In File, select Add Packages.
-
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.
-
In list of Firebase packages, select FirebaseMessaging and select Add Package.
-
(Optional) If you encounter this error when uploading your archive to testflight, get back to your Xcode project.
-
In TARGETS → UnityFramework → Build Settings → Build Option, in “Always Embed Swift Standard Libraries” select No.