Implementing the SDK

Implementing Mobile SDK for Android requires the steps below

Create DengageManager instance

First, you need to create DengageManager instance in your main or launcher activity.

Context context = getApplicationContext();
final DengageManager manager = DengageManager.getInstance(context)
   .setLogStatus(true)
   .setFirebaseIntegrationKey("YOUR_DENGAGE_FIREBASE_APP_INTEGRATION_KEY")
   .setHuaweiIntegrationKey("YOUR_DENGAGE_HUAWEI_APP_INTEGRATION_KEY")
   .useCloudSubscription(false)
   .init();

After these steps, You will be able to send a push notification message to your app.

Change Subscription Api Endpoint

<meta-data
    android:name="den_push_api_url"
    android:value="https://your_push_api_endpoint" />

Note: Please see API Endpoints By Datacenter to set your subscription end point.

Changing Event Api Endpoint

<meta-data
    android:name="den_push_api_url"
    android:value="https://your_push_api_endpoint" />

Note: Please see API Endpoints By Datacenter to set your event end point.

Setting Your User Contact Key

To set user contact key, please use the following methods. If you have user information, you should set contact key.

DengageManager.setContactKey("{user_contact_key}");

Setting Your User Channel Name

Use the following methd to set custome Notification Channel Name for your Android notifications. If name not set default name “General” will used.

DengageManager.getInstance(context).setNotificationChannelName("NOTIFICATION_CHANNEL_NAME") //optional

Viewing Logs

By default, the SDK does not show logs. To show logs, Please use the following method;

DengageManager.setLogStatus(true);

User Permission Management (optional)

If you have in application permission management for push notification, (for example, if you have Notification permission in settings page or such) you can set user’s permission by setPermission function.

DengageManager.setUserPermission(true);

Boolean perm = DengageManager.getUserPermission();

Getting Mobile Push Token

If you want to change a subscription value at runtime. Please use the syncSubscription() method.

DengageManager.getSubscription().token;

Using The SDK with obfuscation (minifyEnabled)

Client apps that obfuscate D-engage SDK code must store release mapping files for SDK to work properly. If you are using the minifyEnabled option as a build parameter, add the following to your Proguard file:

-dontwarn com.dengage.sdk.**
-keep class com.dengage.sdk.** { *; }
-keepclassmembers enum * { *; }

Deeplink

SDK supports URL schema deeplink. If target url has a valid link, it will redirect to the related link.

Please see related links below about deeplinking.

Android Push Notification Transparent Small Icon

Have you noticed a notification bar with an icon that is just a solid white square? Or are you having trouble rendering your Logo correctly on the Android notification bar post Lollipop release?

First, let’s understand the Android documentation which is as follows – “Update or removes assets that involve colour. The system ignores all non-alpha channels in action icons and in the main notification icon. You should assume that these icons will be alpha-only. The system draws notification icons in white and action icons in dark grey.”

So let me explain in detail how you can convert your notification icon to an Android-friendly one with a few clicks.

In your favourite image editor open up your icon file. Convert all parts of the image that you don’t want to show to transparent pixels. All colours and non-transparent pixels are displayed in white. Let us go through an example.

Make sure your file is of the PNG file format with a transparent background. Following these steps will ensure that your logo shows up as expected in Android 5 and above.

(Android Studio 3.5) If you’re using a recent version of Android Studio, you can generate your notification images. Right-click on your res folder > New > Image Asset. You will then see Configure Image Assets as shown in the image below. Change Icon Type to Notification Icons. Your images must be white and transparent. These Configure Image Assets will enforce that rule.

Important: If you want the icons to be used for cloud/push notifications, you must add the meta-data under your application tag to use the newly created notification icons.

You can use the method to change the icon color.

<meta-data
            android:name="den_push_small_icon_color"
            android:value="R50"/>

<meta-data
            android:name="den_push_small_icon"
            android:value="ic_dengage_push" />

The Android operating system, on the other hand, offers some conditions for this logo to work properly;

  • The background of the logo must be absolutely transparent. There will be no layer behind the logo and the logo must be a single layer.

  • He recommends brands to use only one letter in the logo. (For example: When you receive a mail from gmail, only the letter G is shown in the status bar)

  • Another important issue is the fact that the end user is using the device in dark mode or light mode due to the condition that the background to be added must be transparent (it can be called vector), affecting visibility. If the logo is white it will not appear in light mode, if the logo is black it will not appear in light mode.