PushNotifications

Adobe AIR native extension

Push Notifications Adobe AIR Native Extension

The extension is available here: com.distriqt.PushNotifications

Documentation

One Signal

This ANE implements the OneSignal iOS and Android SDKs for usage in your mobile AIR applications.

OneSignal is a high volume and reliable push notification service for websites and mobile applications. They support all major native and mobile platforms by providing dedicated SDKs for each platform, a RESTful server API, and an online dashboard for marketers to design and send push notifications.

OneSignal provides a simple interface to push notifications, letting content creators focus on quality user engagement instead of complex implementation.

Required For Setup

Required ANEs

To use this service add the com.distriqt.PushNotifications.OneSignal.ane variant of the extension to your project in place of com.distriqt.PushNotifications.ane. You should only add one of the variants to your project. If you need to support multiple services please use the All Services variant.

All variants of the Push Notifications extension have the same extension id: com.distriqt.PushNotifications so you should add this to your extensions list in your application descriptor:

<extensions>
	...
	
	<extensionID>com.distriqt.PushNotifications</extensionID>
	
	...
</extensions>
Make sure you have added the common ANEs from the ![](Add the Extension i.Add the Extension) section first. This includes the Core and Android Support ANEs.

Android Support ANE

Due to several of our ANE’s using the Android Support library the library has been separated into a separate ANE allowing you to avoid conflicts and duplicate definitions. This means that you need to include the some of the android support native extensions in your application along with this extension.

You will add these extensions as you do with any other ANE, and you need to ensure it is packaged with your application. There is no problems including this on all platforms, they are just required on Android.

This ANE requires the following Android Support extensions:

You can access these extensions here: https://github.com/distriqt/ANE-AndroidSupport.

Note: if you have been using the older com.distriqt.AndroidSupport.ane you should remove that ANE and replace it with the equivalent com.distriqt.androidsupport.V4.ane. This is the new version of this ANE and has been renamed to better identify the ANE with regards to its contents.

Google Play Services

This ANE requires usage of certain aspects of the Google Play Services client library. The client library is available as a series of ANEs that you add into your applications packaging options. Each separate ANE provides a component from the Play Services client library and are used by different ANEs. These client libraries aren’t packaged with this ANE as they are used by multiple ANEs and separating them will avoid conflicts, allowing you to use multiple ANEs in the one application.

This ANE requires the following Google Play Services:

Optional:

You must include the above native extensions in your application along with this extension, and you need to ensure they are packaged with your application.

You can access the Google Play Services client library extensions here: https://github.com/distriqt/ANE-GooglePlayServices.

If you have used an older version of this ANE you should remove the Play Services GCM ANE. It is no longer required.

Firebase

OneSignal now uses Firebase Cloud Messaging (FCM) on Android. To use Firebase Cloud Messaging you must have access to the Firebase ANE which includes the core Firebase dependencies.

You do not need to initialise or configure this

Extension IDs

The following should be added to your extensions node in your application descriptor to identify all the required ANEs in your application:

<extensions>
    <extensionID>com.distriqt.PushNotifications</extensionID>
    
	<extensionID>com.distriqt.Core</extensionID>

    <extensionID>com.distriqt.Firebase</extensionID>
    <extensionID>com.distriqt.androidsupport.V4</extensionID>
    <extensionID>com.distriqt.androidsupport.CustomTabs</extensionID>
    <extensionID>com.distriqt.playservices.Base</extensionID>
</extensions>

iOS

Firstly make sure you have generated your iOS Push Certificates. You can follow the guide by OneSignal:

Info Additions and Entitlements

Push notifications require a few additions to the Info plist and Entitlements section of your application to correctly configure your application for push notifications.

You should add the listing below to application descriptor iPhone node.

You must replace the BUNDLE_SEED_ID and BUNDLE_IDENTIFIER with the information you gathered when setting up your application. Also make sure you set the environment correctly either using production or development, both are shown in the example below with the production version commented out. More on this below.

<iPhone>
	<InfoAdditions><![CDATA[
		<key>UIPrerenderedIcon</key>
		<true/>
		
		<key>UIDeviceFamily</key>
		<array>
			<string>1</string>
			<string>2</string>
		</array>
	
        <key>UIBackgroundModes</key>
		<array>
			<string>remote-notification</string>
		</array>
		
	)></InfoAdditions>
	<requestedDisplayResolution>high</requestedDisplayResolution>
	<Entitlements><![CDATA[
		
		<!-- DEVELOPMENT -->
		<key>get-task-allow</key>
		<true/>
		<key>aps-environment</key>
		<string>development</string>
		
		<!-- PRODUCTION -->
		<!--
		<key>get-task-allow</key>
		<false/>
		<key>aps-environment</key>
		<string>production</string>
		-->
		
		<key>application-identifier</key>
		<string>BUNDLE_SEED_ID.BUNDLE_IDENTIFIER</string>
		<key>keychain-access-groups</key>
		<array>
			<string>BUNDLE_SEED_ID.*</string>
		</array>
		
	)></Entitlements>
</iPhone>

The first entitlement field is the aps-environment. This field indicates whether we are using the development or the production environment. It must be either development or production and depends on which configuration you are using. If you are running a debug build you should use development. If you are looking to publish the application to the AppStore, you should use production.

You should have noted the BUNDLE_SEED_ID (or App ID Prefix) and BUNDLE_IDENTIFIER when you were setting up your application in the iOS developer center. The seed id should be a unique ten character string and the identifier should be similar to your AIR application id.

Android

Firstly make sure you have generated your Google Service API Key. You can follow the guide by OneSignal:

Manifest Additions

You must add all the OneSignal related manifest additions along with several additions for Cloud Messaging. This includes all the manifest additions required for Firebase core / analytics implementation.

The following shows the complete manifest additions node. You must replace APPLICATION_PACKAGE with your AIR application’s Java package name, something like air.com.distriqt.test. Generally this is your AIR application id prefixed by air. unless you have specified no air flair in your build options.

<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-permission android:name="android.permission.VIBRATE" />
	<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

	<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
	<permission android:name="APPLICATION_PACKAGE.permission.C2D_MESSAGE" android:protectionLevel="signature" />
	<uses-permission android:name="APPLICATION_PACKAGE.permission.C2D_MESSAGE" />
	<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE" />


	<!-- 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" />
	

	<application>
		<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

		<activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
			android:theme="@android:style/Theme.Translucent.NoTitleBar"
			android:exported="false"/>


		<!-- ONE SIGNAL -->
		<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" >

			<!-- High priority so OneSignal payloads can be filtered from other GCM receivers if filterOtherGCMReceivers is enabled. -->
			<intent-filter android:priority="999" >
				<action android:name="com.google.android.c2dm.intent.RECEIVE" />
				<category android:name="APPLICATION_PACKAGE" />
			</intent-filter>
		</receiver>
		<receiver android:name="com.onesignal.NotificationOpenedReceiver" />

		<service android:name="com.onesignal.GcmIntentService" /> <!-- For Android O -->
		<service
			android:name="com.onesignal.GcmIntentJobService"
			android:permission="android.permission.BIND_JOB_SERVICE" />
		<service
			android:name="com.onesignal.SyncJobService"
			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" /> <!-- END - For Android O -->
		<service android:name="com.onesignal.SyncService" />

		<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.ACTION_BOOT_COMPLETED" />
				<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>


		<!-- FIREBASE CORE -->
		<!-- common -->
		<service android:name="com.google.firebase.components.ComponentDiscoveryService" >
			<meta-data
				android:name="com.google.firebase.components:com.google.firebase.analytics.connector.internal.AnalyticsConnectorRegistrar"
				android:value="com.google.firebase.components.ComponentRegistrar" />
			<meta-data
				android:name="com.google.firebase.components:com.google.firebase.iid.Registrar"
				android:value="com.google.firebase.components.ComponentRegistrar" />
		</service>
		<provider
			android:authorities="APPLICATION_PACKAGE.firebaseinitprovider"
			android:name="com.google.firebase.provider.FirebaseInitProvider"
			android:exported="false"
			android:initOrder="100" />

		<!-- analytics -->
		<receiver
			android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
			android:enabled="true"
			android:exported="false" >
		</receiver>
		<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" />

		<!-- iid -->
		<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" />

				<category android:name="APPLICATION_PACKAGE" />
			</intent-filter>
		</receiver>
		<!--
				FirebaseInstanceIdService performs security checks at runtime,
				no need for explicit permissions despite exported="true"
		-->
		<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>


	</application>
	
</manifest>