-
Notifications
You must be signed in to change notification settings - Fork 16
A.4. Initialize Firebase in your app
Initializing Firebase in your Adobe Air project is super easy. First you should import the core Firebase class:
import com.myflashlab.air.extensions.firebase.core.Firebase;
Then, simply call:
Firebase.init();
NOTE 1: Firebase should 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.
NOTE 2: 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.
NOTE 3: 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"/>
<!--
Required by firebase_iid.ane
Change "air.com.doitflash.firebaseCore" to your own app package name
-->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="air.com.doitflash.firebaseCore.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="air.com.doitflash.firebaseCore.permission.C2D_MESSAGE" />
<application>
<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 "air.com.doitflash.firebaseCore" to your own app package name -->
<data android:scheme="air.com.doitflash.firebaseCore" />
</intent-filter>
</activity>
<!--
Required by the firebase_common.ane
Change "air.com.doitflash.firebaseCore" to your own app package name
-->
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="air.com.doitflash.firebaseCore.firebaseinitprovider"
android:exported="false"
android:initOrder="100" />
<!-- Required by the googlePlayServices_basement.ane -->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<!--
Required by firebase_iid.ane
Change "air.com.doitflash.firebaseCore" to your own app package name
-->
<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" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="air.com.doitflash.firebaseCore" />
</intent-filter>
</receiver>
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
<service android:name="com.google.firebase.iid.FirebaseInstanceIdService" android:exported="true">
<intent-filter android:priority="-500">
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<!-- 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 8.0 or higher can support this ANE-->
<key>MinimumOSVersion</key>
<string>8.0</string>
</InfoAdditions>
<!--
Embedding the ANE:
-->
<extensions>
<!--
Download the dependency ANEs from https://github.com/myflashlab/common-dependencies-ANE
-->
<extensionID>com.myflashlab.air.extensions.dependency.firebase.common</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.firebase.iid</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.appinvite</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.tasks</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidSupport</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.overrideAir</extensionID> <!-- Required for iOS and Android -->
<!-- And finally embed the Firebase core ANE -->
<extensionID>com.myflashlab.air.extensions.firebase.core</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