Setup Push Notifications in Unity iOS project using Firebase Cloud Messaging Backend

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video I will show you how to set up push notifications in unity iOS project using Firebase backend let's go to Firebase console create a test project and let's do some basic setup once the project is ready click on the unity icon to add Firebase Unity app select the register as Apple app checkbox then fill in the Apple bundle ID optionally we can set a nickname to this project we don't need to download this Firebase config file right now as we will be making few more changes and download it later however we need to download the Firebase SDK so go ahead and download that continue to the console let's go to the project settings scroll to the end and set the team ID this step is optional let's switch to the Cloud messaging tab under Apple app configuration we need to set up Apple push notifications authentication key this step is very important we have to create this key in apple developer account and upload it here for that let's go to Apple developer account under Keys click on create key enter the key name enable Apple push notification service click on continue then click on register once done download this key back in the Firebase console upload this key file for the key ID go back to the developer account copy the key ID and paste it here click upload now we are done with the basic setup so go to the general and download the Firebase config file okay now that we have the Firebase SDK and the config file let's start creating a test app in unity first let's change the platform to iOS let's go to the project settings here we have to change the bundle identifier to the same one as the one we used in Firebase console optionally you can set up automatic signing from here for Firebase push notifications to work we just need Firebase messaging package from the Firebase SDK that we downloaded earlier so drag and drop this package into the unity project to start importing it click on import once done drag and drop the configuration file as well we added all the files needed from the Firebase let's start writing some Scripts create a scripts folder inside the scripts folder create a script called push notifications manager in the hierarchy create a empty game object and rename it to Scripts under scripts I will create another empty game object and rename it to push notifications manager this is just to keep the hierarchy clean now let's drag and drop the script open the scripts file to start editing first I will remove unnecessary code then paste in some code and explain Firebase messaging Library will be automatically initialized after adding handlers for the token received or message received events but before doing this I am calling Firebase function called check and fix dependencies async what this function does is it first checks for dependencies if there are any issues it will fix automatically for us with that we made all the changes we need on the client side so let's go ahead and Export the xcode project from Unity for that I am going to file build settings click on build and run I'm exporting xcode project here under tutorial one folder click this select the project under the build settings search for bit code we need to disable this otherwise we will see this error message next select the targets Unity iPhone switch to signing and capabilities tab here we need to add some capabilities for Firebase messaging to work for more details refer to Firebase documentation click on the capabilities add button search for push notification select that and hit enter to add it again click on the capabilities add background modes then enable remote notifications now let's start building the project push notifications will only work in physical devices so what I did is capture the video in device directly and overlaying it here for you to follow along once it is launched it will automatically show push notifications pop up and obviously we'll have to allow it in order to test this another important thing is after allowing push notifications go to xcode console looks for token received messages and then copy the token ID which we'll use for testing later back in the Firebase console under engage click messaging from here we can start sending test notifications click on create your first campaign button check Firebase notification messages click on create button here we can compose our messages so set the title and text message click on send test message button paste the token ID we copied from the xcode console earlier then click this little plus icon then click test you will see this message almost immediately let's start testing this globally change the title and test to differentiate it set the app appropriately schedule now click review and publish this notification takes usually bit longer while recording this video it took almost like two minutes for me to receive the notification this way I just trimmed that recording in this video thanks for watching
Info
Channel: ThatTechSavvy
Views: 2,098
Rating: undefined out of 5
Keywords:
Id: jETcNMdyzuM
Channel Id: undefined
Length: 7min 27sec (447 seconds)
Published: Fri May 26 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.