-
Notifications
You must be signed in to change notification settings - Fork 16
G.1 Add FCM
- Make sure you are considering the minimum requirements for running Firebase.
- Install the Firebase SDK.
- In the Firebase console, add your app to your Firebase project.
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>
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