Firebase and AdMob iOS Support
RAD Studio introduces two new features specific to the iOS platform related to Google Firebase support and the Google AdMob. Between them you can find:
- The ability to receive push notifications from the Firebase Cloud Messaging (FCM) service.
- The ability to present advertising banners from the AdMob service, including the integration with analytics capabilities from the Firebase Analytics service.
Both features have a dependency on the Firebase SDK for iOS, delivered via GetIt.
As the Firebase Cloud Messaging service uses the Apple Push Notification service (APNs) to send push notifications to an iOS application, you need to:
- Create a provisioning profile that enables the Push Notifications capability.
- Create an APNs authentication key to allow your iOS application to use the FCM service.
Contents
Create a provisioning profile to enable push notifications in your iOS application
To allow your iOS application to receive push notifications, you need to create and install a provisioning profile on your macOS device.
If you have an existing provisioning profile, you can use it instead of creating a new one. Otherwise, follow the steps below:
- Browse the https://developer.apple.com web page.
- Login with your Apple Developer credentials.
- Select the Certificates, IDs & Profiles menu.
- On the Identifiers menu, click the “+” button to add a new identifier.
- Select the App IDs option and click Continue.
- Select the App IDs option and click Continue.
- Enter a description and a bundle identifier.
- Enable the Push Notifications capability and click Continue.
- Confirm the application identifier and click Register.
- On the Profiles tab, click the “+” button to add a new Provisioning Profile.
- Select the iOS App Development option and click Continue.
- Select the application identifier registered before and click Continue.
- Select the development certificate(s) to include in the provisioning profile, and click Continue.
- Select the test device(s) to include in the provisioning profile, and click Continue.
- Enter a provisioning profile name and click Generate.
- Click Download and install the provisioning profile on the macOS machine.
Create an APNs authentication key
To allow your Firebase project to send push notifications to your application through the Apple Push Notification service (APNs), you need to create an APNs authentication key. To do so, follow the steps below.
Prepare your iOS application to use the Firebase Cloud Messaging service
In RAD Studio, the new FMX.PushNotification.FCM.iOS unit implements the support for the iOS platform to push notifications from the Firebase Cloud Messaging service. The FCM support relies on the APIs from the System.PushNotification unit, therefore, is possible to use the same code for Android and iOS platforms.
Create a Firebase project
- Browse the https://console.firebase.google.com web page.
- Click +Add Project.
- Enter a name for your project and click Continue.
- Consider disabling the Google Analytics integration at this moment and click Continue. It can be enabled later.
iOS Project prerequisites
To add Firebase to your iOS Project make sure to meet the following prerequisites:
- Install Xcode 11.0 or later and CocoaPods 1.9.0 or later.
- The project must target iOS 10 or later.
- An Apple Push Notification Key for your Apple Developer account.
- Enable Push Notifications in XCode under App > Capabilities.
- Sign in to FireBase using your Google account.
Add Firebase to you iOS Project
Follow the next steps to add firebase to your iOS project:
- Create a Firebase project to connect your iOS application.
- Register your application with FireBase.
- Add a Firebase configuration File.
- Add Firebase SDKs to your app.
- Add the APNs authentication key.
- Initialize Firebase in your app.
- Register your application for remote notification.
Access the registration token
Firebase Cloud Messaging (FCM) SDK generates a registration token by default. This token allows you to send targeted notifications to any particular instance of the iOS app. Also, Firebase Cloud Messaging (FCM) SDK retrieves a new or existing token during the application launch and whenever the token is updated or invalidated.
Firebase Mobile Ads
Active the Firebase advertising by dropping the FirebaseBannerAd component on a form.
To finish the configuration, set the following runtime properties:
- AdSize: TFirebaseBannerAdSize
- AdUnitID: string
- Model: TCustomFirebaseBannerAdModel
- TestMode: Boolean
Also, you can configure the LoadAd key method and some event handlers:
- OnDidDismissScreen
- OnDidFailToReceiveAd
- OnDidReceiveAd
- OnWillDismissScreen
- OnWillLeaveApplication
- OnWillPresentScreen
For more information check the FMX.Advertising.Firebase unit.
Firebase SDK via GetIt
To build applications using Firebase on iOS you need to install on your development machine the Firebase SDK provided by Google.
This installation will be provided soon via a specific GetIt package, check the GetIt package manager for availability.
Alternatively, you can accept the license and download the SDK directly from Google see the main Firebase SDK for iOS on the GitHub site:
on a specific download link such as:
You can also get the latest version at