-
Notifications
You must be signed in to change notification settings - Fork 16
A.4. Initialize Firebase in your app
Initializing Firebase in your AdobeAIR project is super easy. First you should import the core Firebase package:
import com.myflashlab.air.extensions.firebase.core.*;
Then, simply call:
Firebase.init();
-
Firebase must be initialized in your app as soon as possible. The best location for initializing the Firebase ANE, is in the constructor function of your app document-class.
-
The
Firebase.init();
method returns a Boolean value which indicates if the ANE has been able to correctly locate the Firebase config files. If you have not yet added the config files to your project, make sure to read this Wiki. -
If you are trying to enable DynamicLinks in your app, you need to pass
true
to the Firebase init method.Firebase.init(true);
-
FirebaseAuth ANE, has many APIs based on DynamicLinks ANE. To avoid unpredicted errors, implement DynamicLinks to your app prior to implementing the Auth ANE.
-
If you want to use the phone number authentcation with the FirebaseAuth ANE, you need to have activated the FCM ANE first.
-
Run your app on a real device not on a simulator.
Before running your app, you should make sure your AIR manifest .xml file is configured correctly. The firebaseCore.ane
requires you to configure your manifest file as follow. Other Firebase features may need additional setups which will be explained in their own documentations.
<!--
FOR ANDROID:
-->
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-sdk android:targetSdkVersion="28"/>
<!-- Required by the googlePlayServices_measurementBase.ane -->
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE"/>
<!-- Required by firebase_iid.ane -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<!-- Activate multidex for older Android support -->
<application android:name="android.support.multidex.MultiDexApplication">
<activity>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<!-- Change "[YOUR_APP_PACKAGE_NAME]" to your own app package name -->
<data android:scheme="[YOUR_APP_PACKAGE_NAME]" />
</intent-filter>
</activity>
<!-- Required by the googlePlayServices_measurementBase.ane -->
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
android:enabled="true"
android:exported="false"/>
<receiver
android:name="com.google.android.gms.measurement.AppMeasurementInstallReferrerReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>
<service
android:name="com.google.android.gms.measurement.AppMeasurementService"
android:enabled="true"
android:exported="false"/>
<service
android:name="com.google.android.gms.measurement.AppMeasurementJobService"
android:enabled="true"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"/>
<!-- Required by googlePlayServices_basement.ane -->
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
<!--
Required by androidx_lifecycle.ane
Change "[YOUR_APP_PACKAGE_NAME]" to your own app package name
-->
<provider
android:name="androidx.lifecycle.ProcessLifecycleOwnerInitializer"
android:authorities="[YOUR_APP_PACKAGE_NAME].lifecycle-process"
android:exported="false"
android:multiprocess="true"/>
<!--
Required by the firebase_common.ane
Change "[YOUR_APP_PACKAGE_NAME]" to your own app package name
-->
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="[YOUR_APP_PACKAGE_NAME].firebaseinitprovider"
android:exported="false"
android:initOrder="100" />
<service android:name="com.google.firebase.components.ComponentDiscoveryService" android:exported="false">
<!-- Required by firebase_iid.ane -->
<meta-data
android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
android:value="com.google.firebase.components.ComponentRegistrar"/>
<!-- Required by googlePlayServices_measurementBase.ane -->
<meta-data
android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar"/>
</service>
<!-- Required by firebase_iid.ane -->
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</receiver>
<!-- Required by googlePlayServices_base.ane -->
<activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:exported="false"/>
</application>
</manifest>
<!--
FOR iOS:
-->
<InfoAdditions>
<!--iOS 10.0 or higher can support this ANE-->
<key>MinimumOSVersion</key>
<string>10.0</string>
</InfoAdditions>
<!--
Embedding the ANE:
-->
<extensions>
<!-- FirebaseCore ANE -->
<extensionID>com.myflashlab.air.extensions.firebase.core</extensionID>
<!-- Dependency ANEs for FirebaseCore -->
<extensionID>com.myflashlab.air.extensions.dependency.overrideAir</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.arch</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.core</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.lifecycle</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.firebase.analytics</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.firebase.common</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.firebase.iid</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.firebase.measurement.connector</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.base</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.basement</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.measurementBase</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.ads</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.stats</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.tasks</extensionID>
</extensions>
-->
Enjoy building Air apps – With ♥ from MyFlashLabs Team
Introduction to Firebase ANEs collection for Adobe Air apps
Get Started with Firebase Core in AIR
- Prerequisites
- Add Firebase to your app
- Add the Firebase SDK
- Init Firebase Core
- Available ANEs
- Managing Firebase iid
Get Started with Authentication
- Add Authentication
- Init Authentication
- Manage Users
- Phone Number
- Custom Auth
- Anonymous Auth
- State in Email Actions
- Email Link Authentication
Get Started with FCM + OneSignal
- Add FCM ANE
- Init FCM ANE
- Send Your 1st Message
- Send Msg to Topics
- Understanding FCM Messages
- init OneSignal
- Add Firestore
- Init Firestore
- Add Data
- Transactions & Batches
- Delete Data
- Manage the Console
- Get Data
- Get Realtime Updates
- Simple and Compound
- Order and Limit Data
- Paginate Data
- Manage Indexes
- Secure Data
- Offline Data
- Where to Go From Here
Get Started with Realtime Database
- Add Realtime Database
- Init Realtime Database
- Structure Your Database
- Save Data
- Retrieve Data
- Enable Offline Capabilities
Get Started with Remote Config
- Add Storage ANE
- Init Storage ANE
- Upload Files to Storage
- Download Files to Air
- Use File Metadata
- Delete Files