EN - How to reproduce Accengage BigTextBigPicture template on Airship?

Ce contenu est également disponible en français.

 

This article will walk you through our recommendations to reproduce Accengage BigTextBigPicture template on Airship.

The steps listed below need to be realized by an Android developer.

Accengage

On Accengage, it is possible to use various templates message types for Android:

  • Default templates

    • BigText: notification contains a title, a long text, a short customized text and buttons. Image is unavailable for this template.

    • BigPicture: notification contains a title, a short customized text, an image and buttons. Long text is unavailable for this template.

    • BigTextBigPicture: notification contains a title, a long text, a short customized text and an image. Buttons are unavailable for this template.

  • Custom templates

     

Airship 

On Airship, only BigText and BigPicture templates are available by default as both templates are Android native format. On the other hand, BigTextBigPicture is unavailable.

However, it is possible to create a custom template identical to BigTextBigPicture. To create it, it is necessary to follow the steps below:

 

Step 1 : Create a layout custom_template.xml

Create the layout custom_template.xml following the structure below:

  • App folder

    • Res 

      • Layout 

This structure must be respected when creating the layout.

 

To create the layout custom_template.xml based on Accengage BigTextBigPicture template’s design with, you need to :

  • Create the template

  • Define the sizes of all the views integrated with the layout. (Here is an example of the BigTextBigPicture Layout)

  • Define the components' ids (icon, message, title, image)

 

Step 2 : Create a NotificationProvider MyLayoutNotificationProvider.java

In Java, you can place the class where you would like.

Example:

  • Java 

    • Com 

      • Urbanairship 

        • Sample 

You’ll then need to:

  1. Create “MyLayoutNotificationProvider” 

  2. Extend the class “CustomLayoutNotificationProvider” (embed in urbanairship-core of the SDK) with  “MyLayoutNotificationProvider”

  3. Implement the builder 

  4. Override the method onBindContentView 

  5. Retrieve the object PushMessage, then replace all the views with the content of the message 

 

You can retrieve the BigPicture in the payload with the key “big_picture” which contains the URL of the image in order to integrate it as a string inside “message.getStylePayload()”.

 

Step 3: Associate your layout with the Airship SDK

To personalize and use the custom NotificationProvider you must extend the Autopilot. To do so, in “onAirshipReady” retrieve the push manager et define the  NotificationProvider:

UAirship.shared().getPushManager()
.setNotificationProvider(new MyLayoutNotificationProvider(UAirship.getApplicationContext(), UAirship.shared().getAirshipConfigOptions(), R.layout.custom_template))

 

No action is necessary on the Airship platform in order to use the BigTextBigPicture template.

All of your pushes will be displayed with the BigTextBigPicture template.

You have the possibility to modify the layout as you would like when sending out your push by using custom keys. This will allow you to use the custom key to choose the template to display on the platform message composer.

Was this article helpful?
0 out of 0 found this helpful
Submit a request