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

G.1 Add FCM

MyFlashLabs edited this page Apr 5, 2020 · 6 revisions

Connect your AdobeAIR app to Firebase

  1. Make sure you are considering the minimum requirements for running Firebase.
  2. Install the Firebase SDK.
  3. In the Firebase console, add your app to your Firebase project.

Add the FCM ANE to your app

Before adding the FCM (or any of the other Firebase child ANEs) to your AdobeAIR app, you need to make sure you have setup the firebaseCore.ane correctly in your project. To add the FCM, you need to add the required ANEs and Frameworks to your project. These dependencies are explained in details in this document.

Notice: If you are looking into enabling OneSignal into your app, you must first enable FCM as described below. After FCM implementation is completed, you should start adding OneSignal configuration explained at the bottom of this page.

AIR manifest .xml file
Beside changes you need to make to your manifest .xml file when implementing the firebaseCore.ane you need to add the following changes also to make the FCM ANE works properly:

<android>
	<manifestAdditions>
		<manifest android:installLocation="auto">
			<application>
				
				<!-- 
					Other settings required by the Firebase core or other ANEs...
				-->


				<!-- Required by firebase_addons_fcm.ane -->
				<service
					android:name="com.google.android.datatransport.runtime.backends.TransportBackendDiscovery"
					android:exported="false">
					<meta-data
						android:name="backend:com.google.android.datatransport.cct.CctBackendFactory"
						android:value="cct"/>
				</service>
				<service
					android:name="com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService"
					android:exported="false"
					android:permission="android.permission.BIND_JOB_SERVICE"/>
				<receiver
					android:name="com.google.android.datatransport.runtime.scheduling.jobscheduling.AlarmManagerSchedulerBroadcastReceiver"
					android:exported="false"/>

				<!-- 
					Add this meta-data tag under <service android:name="com.google.firebase.components.ComponentDiscoveryService" android:exported="false">

					You should have added the above service tag when you were implementing the FirebaseCore ANE.
				-->

				<service android:name="com.google.firebase.components.ComponentDiscoveryService" android:exported="false">
					<!--
						Other meta-data tags required by other ANEs.
					-->

					<!-- Required by firebase_messaging.ane -->
					<meta-data
						android:name="com.google.firebase.components:com.google.firebase.messaging.FirebaseMessagingRegistrar"
						android:value="com.google.firebase.components.ComponentRegistrar"/>

					<!-- Required by firebase_datatransport.ane -->
					<meta-data
						android:name="com.google.firebase.components:com.google.firebase.datatransport.TransportRegistrar"
						android:value="com.google.firebase.components.ComponentRegistrar"/>
				</service>

				
				<!-- Required by firebase_messaging.ane -->
				<service android:name="com.myflashlab.firebase.fcm.MyFirebaseMessagingService" android:exported="false">
					<intent-filter>
						<action android:name="com.google.firebase.MESSAGING_EVENT"/>
					</intent-filter>
				</service>
				<activity 
					android:name="com.myflashlab.firebase.fcm.MyFirebaseMessagingIntent" 
					android:theme="@style/Theme.Transparent"
					android:exported="false"
					android:noHistory="true"
					android:clearTaskOnLaunch="true"
					android:hardwareAccelerated="false"
					android:stateNotNeeded="true">
					<intent-filter>
						<action android:name="MY_INTENT" />
						<category android:name="android.intent.category.DEFAULT" />
					</intent-filter>
				</activity>
				
			</application>
		</manifest>
	</manifestAdditions>
</android>



<iPhone>
	<InfoAdditions>
		
		<!-- 
			Other settings required by the Firebase core or other ANEs...
		-->
		
		<!-- Required by firebase_messaging.ane -->
		<key>UIBackgroundModes</key>
		<array>
			<string>remote-notification</string>
		</array>
		
	</InfoAdditions>
	
	<requestedDisplayResolution>high</requestedDisplayResolution>
	
	<Entitlements>
	
		<!--
			Open your *.mobileprovision file with a text editor and find
			the Entitlements tag. copy it all here like the sample below.
			
			BUT, make sure you are reading the comments below to know what
			you have to change when you are trying to build for adhoc or
			distribution vs development mode.
		-->
		
		<key>keychain-access-groups</key>
		<array>
			<string>57AX1RU6SZ.*</string>		
		</array>
		
		<!-- 
			set to 'true' when debugging your app and set to 'false' when 
			building for adhoc or distribution.
		-->
		<key>get-task-allow</key>
		<true/>
		
		<key>application-identifier</key>
		<string>57AX1RU6SZ.your.app.package.name</string>
		<key>com.apple.developer.team-identifier</key>
		<string>57AX1RU6SZ</string>
		
		<!-- 
			set to 'development' when debugging your app and set to 
			'production' when building for adhoc or distribution.
		-->
		<key>aps-environment</key>
		<string>development</string>
		
		<!-- 
			Apple has silently added this key which is required ONLY 
			when you are trying to upload your binary to itunesconnect 
		-->
		<!--<key>beta-reports-active</key>
		<false/>-->	
	
	</Entitlements>
	
</iPhone>



<extensions>
	
	<!-- 
		Required ANEs for the Firebase Core ANE comes here first.
		https://github.com/myflashlab/Firebase-ANE/wiki/A.4.-Initialize-Firebase-in-your-app
	-->
	
	<!-- To support Firebase FCM -->
	<extensionID>com.myflashlab.air.extensions.firebase.fcm</extensionID>
	
	<!-- 
		Download the dependency ANEs from https://github.com/myflashlab/common-dependencies-ANE
		These dependencies are not required on the iOS side.
	-->
	<extensionID>com.myflashlab.air.extensions.dependency.firebase.messaging</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.firebase.datatransport</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.firebase.encoders.json</extensionID>
	<extensionID>com.myflashlab.air.extensions.dependency.firebase.addons.fcm</extensionID>
	
</extensions>

AIR manifest .xml configuration for OneSignal
Make sure you have already implemented FCM in your app and then continue reading below.

<!-- Android -->

<!-- 
	The following permissions must be added out side the Android <application> tag 
	make sure to replce {PACKAGE_NAME} with correct data.
-->

<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<permission android:name="{PACKAGE_NAME}.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="{PACKAGE_NAME}.permission.C2D_MESSAGE"/>

<!-- Samsung -->
<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
<!-- HTC -->
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT"/>
<!-- Sony -->
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE"/>
<uses-permission android:name="com.sonymobile.home.permission.PROVIDER_INSERT_BADGE"/>
<!-- Apex -->
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT"/>
<!-- Solid -->
<uses-permission android:name="com.majeur.launcher.permission.UPDATE_BADGE"/>
<!-- Huawei -->
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE"/>
<uses-permission android:name="com.huawei.android.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS"/>
<!-- ZUK -->
<uses-permission android:name="android.permission.READ_APP_BADGE"/>
<!-- OPPO -->
<uses-permission android:name="com.oppo.launcher.permission.READ_SETTINGS"/>
<uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"/>
<!-- EvMe -->
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_READ"/>
<uses-permission android:name="me.everything.badger.permission.BADGE_COUNT_WRITE"/>



<!-- 
	The following permissions must be added inside the Android <application> tag 
	make sure to replce {ONESIGNAL_APP_ID} and {PACKAGE_NAME} with correct data.
-->

<meta-data android:name="onesignal_app_id" android:value="{ONESIGNAL_APP_ID}"/>
<meta-data android:name="onesignal_google_project_number" android:value="str:REMOTE"/>
<receiver
    android:name="com.onesignal.GcmBroadcastReceiver"
    android:permission="com.google.android.c2dm.permission.SEND">

    <intent-filter android:priority="999">
        <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
        <category android:name="{PACKAGE_NAME}"/>
    </intent-filter>
</receiver>
<receiver android:name="com.onesignal.NotificationOpenedReceiver"/>
<service android:name="com.onesignal.GcmIntentService"/>
<service android:name="com.onesignal.GcmIntentJobService" android:permission="android.permission.BIND_JOB_SERVICE"/>
<service android:name="com.onesignal.RestoreJobService" android:permission="android.permission.BIND_JOB_SERVICE"/>
<service android:name="com.onesignal.RestoreKickoffJobService" android:permission="android.permission.BIND_JOB_SERVICE"/>
<service android:name="com.onesignal.SyncService" android:stopWithTask="true"/>
<service android:name="com.onesignal.SyncJobService" android:permission="android.permission.BIND_JOB_SERVICE"/>
<activity android:name="com.onesignal.PermissionsActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
<service android:name="com.onesignal.NotificationRestoreService"/>
<receiver android:name="com.onesignal.BootUpReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.QUICKBOOT_POWERON"/>
    </intent-filter>
</receiver>
<receiver android:name="com.onesignal.UpgradeReceiver">
    <intent-filter>
       <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
    </intent-filter>
</receiver>



<!-- Extra dependencies required if using OneSignal -->
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.places</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.googlePlayServices.location</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.design</extensionID>
<extensionID>com.myflashlab.air.extensions.dependency.androidx.browser</extensionID>





<!-- iOS -->

<!-- 
	Add the following inside the <InfoAdditions> tag 
	make sure to replce {ONESIGNAL_APP_ID} with correct data.
-->
<key>onesignal_app_id</key>
<string>{ONESIGNAL_APP_ID}</string>

if you are planing to use location with OneSignal, add <string>location</string> as follow:

	<key>UIBackgroundModes</key>
    <array>
    	<string>remote-notification</string>
        <string>location</string>
    </array>

	<key>NSLocationWhenInUseUsageDescription</key>
    <string>I need location reason</string>

    <key>NSLocationAlwaysUsageDescription</key>
    <string>I need location reason</string>

	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>I need location reason</string>

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