Advanced Integration
Additional configuration for specific use-cases.
Configuring Airship via properties file
If no config is returned from Autopilot.createAirshipConfigOptions, Airship will default to loading config from the airshipconfig.properties file, located in your application’s assets directory. This can be useful for in Apps with multiple build variants, or for keeping credentials out of version control.
Sample assets/airshipconfig.properties file:
# App credentials
app_key = YOUR_DEFAULT_APP_KEY
app_secret = YOUR_DEFAULT_APP_SECRET
# Optionally, set separate production credentials
# production_app_key = YOUR_PRODUCTION_APP_KEY
# production_app_secret = YOUR_PRODUCTION_APP_SECRET
# development_app_key = YOUR_DEVELOPMENT_APP_KEY
# development_app_secret = YOUR_DEVELOPMENT_APP_SECRET
# Set the cloud site (either SITE_US or SITE_EU)
site = SITE_US
# In production (true/false)
in_production = false
# Enable Airship debug logging (true/false)
is_airship_debug_enabled = true
# Notification configuration
notification_icon = @drawable/ic_notification
notification_accent_color = @color/accent
notification_channel = default_channelThe keys used in the airshipconfig.properties file match the field names in
AirshipConfigOptions
, converted to snake-case.
URL allowlist
The UrlAllowList controls which URLs the Airship SDK is able to act on. The SDK divides up usages of URLs into two different scopes:
SCOPE_OPEN_URL: Only URLs allowed for this scope can be opened from an action, displayed in landing page, or displayed in an HTML in-app message. Defaults to allowing all URLs if not specified in the config.SCOPE_JAVASCRIPT_INTERFACE: These URLs are checked before the Airship JavaScript interface is injected into the webview. Defaults to any Airship originated URLs.
Allowed URLs should be provided when configuring the Airship Config options.
<pattern> := '*' | <scheme>'://'<host>/<path> | <scheme>'://'<host> | <scheme>':/'<path> | <scheme>':///'<path>
<scheme> := <any char combination, '*' are treated as wild cards>
<host> := '*' | '*.'<any char combination except '/' and '*'> | <any char combination except '/' and '*'>
<path> := <any char combination, '*' are treated as wild cards>Custom Firebase applications
By default, the Airship SDK will use the data in google-services.json to configure Firebase Messaging. If your app makes use of multiple Firebase projects, you can instruct the Airship SDK to use a specific named Firebase project for Firebase Cloud Messaging (FCM).
In order to create a secondary Firebase application instance, you’ll need to manually configure FirebaseOptions and initialize your secondary Firebase application. The Firebase application should be initialized before takeOff, or during the onAirshipReady callback.
Initialize the secondary Firebase Application instance
// Manually configure FirebaseOptions for the secondary Firebase Application.
val options = FirebaseOptions.Builder()
.setProjectId("Your Firebase Project ID")
.setApplicationId("Your Firebase Application ID")
.setApiKey("Your Firebase API key")
.setGcmSenderId("Your GCM Sender ID")
.build()
// Initialize the secondary Firebase Application.
Firebase.initialize(context, options, "secondary")// Manually configure FirebaseOptions for the secondary Firebase Application.
FirebaseOptions options = new FirebaseOptions.Builder()
.setProjectId("Your Firebase Project ID")
.setApplicationId("Your Firebase Application ID")
.setApiKey("Your Firebase API key")
.setGcmSenderId("Your GCM Sender ID")
.build();
// Initialize the secondary Firebase Application.
FirebaseApp.initializeApp(context, options, "secondary");Now that you have initialized your secondary Firebase application, you can configure
the Airship SDK to use it by setting
Firebase app name
name in the AirshipConfigOptions instance.
Extending the FirebaseMessagingService
If your application uses its own FirebaseMessagingService or some other third party push provider, you will also need to forward onNewToken and onMessageReceived calls to
the Airship SDK.
Custom FirebaseMessagingService
fun onNewToken(token: String) {
AirshipFirebaseIntegration.processNewToken(getApplicationContext(), token)
}
fun onMessageReceived(remoteMessage: RemoteMessage) {
AirshipFirebaseIntegration.processMessageSync(getApplicationContext(), message)
}@Override
public void onNewToken(String token) {
AirshipFirebaseIntegration.processNewToken(getApplicationContext(), token);
}
@Override
public void onMessageReceived(RemoteMessage message) {
AirshipFirebaseIntegration.processMessageSync(getApplicationContext(), message);
}Extending the HmsMessageService
If your application uses its own HmsMessageService or some other third party push provider, you will also need to forward onNewToken and onMessageReceived calls to
the Airship SDK.
Custom HmsMessageService
fun onNewToken(token: String?) {
AirshipHmsIntegration.processNewToken(getApplicationContext(), token)
}
fun onMessageReceived(remoteMessage: RemoteMessage) {
AirshipHmsIntegration.processMessageSync(getApplicationContext(), message)
}@Override
public void onNewToken(@Nullable String token) {
AirshipHmsIntegration.processNewToken(getApplicationContext(), token);
}
@Override
public void onMessageReceived(RemoteMessage message) {
AirshipHmsIntegration.processMessageSync(getApplicationContext(), message);
}Categories