Skip to content
This repository has been archived by the owner on May 17, 2022. It is now read-only.

A.4. Initialize Firebase in your app

myflashlab edited this page Jul 7, 2016 · 18 revisions

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 initializinf 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" />
			</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 7.0 or higher can support this ANE-->
		<key>MinimumOSVersion</key>
		<string>7.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.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>
	
	<!-- And finally embed the Firebase core ANE -->
	<extensionID>com.myflashlab.air.extensions.firebase.core</extensionID>
	
  </extensions>
-->

Introduction to Firebase ANEs collection for Adobe Air apps


Get Started with Firebase Core in AIR

  1. Prerequisites
  2. Add Firebase to your app
  3. Add the Firebase SDK
  4. Init Firebase Core
  5. Available ANEs
  6. Managing Firebase iid

Get Started with Analytics

  1. Add Analytics ANE
  2. Init Analytics ANE
  3. Log Events
  4. Set User Properties

Get Started with Crashlytics

  1. Add Crashlytics ANE
  2. Test Your Implementation
  3. Customize Crash Reports
  4. Upload .dSYM for iOS apps

Get Started with DynamicLinks

  1. Add DynamicLinks ANE
  2. Init DynamicLinks ANE
  3. Create DynamicLinks
  4. Receive DynamicLinks
  5. View Analytics

Get Started with Authentication

  1. Add Authentication
  2. Init Authentication
  3. Manage Users
  4. Phone Number
  5. Custom Auth
  6. Anonymous Auth
  7. State in Email Actions
  8. Email Link Authentication

Get Started with FCM + OneSignal

  1. Add FCM ANE
  2. Init FCM ANE
  3. Send Your 1st Message
  4. Send Msg to Topics
  5. Understanding FCM Messages
  6. init OneSignal

Get Started with Firestore

  1. Add Firestore
  2. Init Firestore
  3. Add Data
  4. Transactions & Batches
  5. Delete Data
  6. Manage the Console
  7. Get Data
  8. Get Realtime Updates
  9. Simple and Compound
  10. Order and Limit Data
  11. Paginate Data
  12. Manage Indexes
  13. Secure Data
  14. Offline Data
  15. Where to Go From Here

Get Started with Realtime Database

  1. Add Realtime Database
  2. Init Realtime Database
  3. Structure Your Database
  4. Save Data
  5. Retrieve Data
  6. Enable Offline Capabilities

Get Started with Remote Config

  1. Parameters and Conditions
  2. Add Remote Config
  3. Init Remote Config

Get Started with Performance

  1. Add Performance ANE
  2. Init & Start Monitoring

Get Started with Storage

  1. Add Storage ANE
  2. Init Storage ANE
  3. Upload Files to Storage
  4. Download Files to Air
  5. Use File Metadata
  6. Delete Files

Get Started with Functions

  1. Write & Deploy Functions
  2. Add Functions ANE
  3. Init Functions
Clone this wiki locally