Customer Engagement

Using the CEE panel, you can engage with your app users via channels like push notifications & in-app messages.

Setting up Push Notifications for your Android project is a quick 6 steps process.

Step 1: Complete basic setup

Go to Basic Setup to start integrating your Android project with CEE SDK.

Step 2: Adding SmartPush SDK dependency

  1. Please add SmartPush dependency inside the app-level build.gradle file.
implementation 'com.netcore.android:smartech-push:3.2.14'
  1. Perform Gradle Sync to build your project and incorporate the dependency additions noted above.

Step 3: Setting up Proguard rules

Add the following lines in proguard-rules.pro to retain Smartech Push files during the proguard process.

# Smartech Push SDK
-dontwarn com.netcore.android.smartechpush.**
-keep class com.netcore.android.smartechpush.**{*;}
-keep class * implements com.netcore.android.smartechpush.**.* {*;}
-keep class * extends com.netcore.android.smartechpush.**.* {*;}

Step 4: Integrate Firebase Cloud Messaging in your app

Please follow Google’s Documentation to set up FCM SDK in your app, if it is not already done.

Step 5: Send FCM token to CEE SDK

Call the following method in onCreate function of your Application class after initializing the CEE SDK to allow CEE to retrieve existing token

try {
  SmartPush smartPush = SmartPush.getInstance(new WeakReference<>(context));
  smartPush.fetchAlreadyGeneratedTokenFromFCM();
} catch (Exception e) {
  Log.e(TAG, "Fetching FCM token failed.");
}
try {
  val smartPush = SmartPush.getInstance(WeakReference(context))
  smartPush.fetchAlreadyGeneratedTokenFromFCM()
} catch (e: Exception) {
  Log.e(TAG, "Fetching FCM token failed.")
}

Provide token via setDevicePushToken() and notification payload via handlePushNotification() methods to SmartPush SDK. handlePushNotification() method will only display a notification if the Notification payload originated from Netcore and will safely ignore if not. The code of the class should look similar to the following:

public class <YourFirebaseMessagingServiceClass> extends FirebaseMessagingService {

    @Override
    public void onNewToken(@NonNull String token) {
        super.onNewToken(token);
        SmartPush.getInstance(new WeakReference<Context>(this)).setDevicePushToken(token);
      
        //<Your code>
    }

    @Override
    public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        boolean pushHandledBySmartech = SmartPush.getInstance(new WeakReference<>(getApplicationContext())).handlePushNotification(remoteMessage.getData().toString())
        if (!pushHandledBySmartech){
       
         // Handle notification from other sources.
            
       }
    }
}
class AppsFirebaseMessagingService : FirebaseMessagingService() {

    override fun onNewToken(token: String) {
        super.onNewToken(token)
        SmartPush.getInstance(WeakReference(this)).setDevicePushToken(token)
    }

    override fun onMessageReceived(remoteMessage: RemoteMessage) {
        super.onMessageReceived(remoteMessage)
        SmartPush.getInstance(WeakReference(applicationContext)).handlePushNotification(remoteMessage.data.toString())
    }
}

Step 6: Retrieving Deeplink Data

Implement a BroadcastReceiver for the Deeplinks.

public class DeeplinkReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

        Bundle bundleExtra = getIntent().getExtras();
        if (bundleExtra != null) {

            if (bundleExtra.containsKey(SMTBundleKeys.SMT_BUNDLE_KEY_CLICK_DEEPLINK)) {
                String deepLinkvalue = bundleExtra.getString(SMTBundleKeys.SMT_BUNDLE_KEY_CLICK_DEEPLINK);
            } else {
                Log.v("Activity", "does not have deeplink path.");
            }

            if (bundleExtra.containsKey(SMTBundleKeys.SMT_BUNDLE_KEY_CLICK_CUSTOM_PAYLOAD)) {
                String customPayloadvalue = bundleExtra.getString(SMTBundleKeys.SMT_BUNDLE_KEY_CLICK_CUSTOM_PAYLOAD);
            } else {
                Log.v("Activity", "does not have custom payload.");
            }

        }
    }
}
class DeeplinkReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context?, intent: Intent?) {
        val bundleExtra = intent?.extras
        if (bundleExtra != null) {
            if (bundleExtra.containsKey(SMTBundleKeys.SMT_BUNDLE_KEY_CLICK_DEEPLINK)) {
                val deepLinkvalue = bundleExtra.getString(SMTBundleKeys.SMT_BUNDLE_KEY_CLICK_DEEPLINK)
            } else {
                Log.v("Activity", "Does not have deeplink path.")
            }
            if (bundleExtra.containsKey(SMTBundleKeys.SMT_BUNDLE_KEY_CLICK_CUSTOM_PAYLOAD)) {
                val customPayloadvalue = bundleExtra.getString(SMTBundleKeys.SMT_BUNDLE_KEY_CLICK_CUSTOM_PAYLOAD)
            } else {
                Log.v("Activity", "Does not have custom payload.")
            }
        }
    }
}
SmartPush.addListener(Smartech.SmartPushDeeplinkNotification, handleDeeplinkWithPayload);
    SmartPush.getDeepLinkUrl(function (_response) {
      console.log('getDeepLinkUrl Initial Deeplink Response ', _response);
      // Handling the SDK Deeplink Callback.
    });
  const handleDeeplinkWithPayload = (deeplinkdata) => {
  };

Register the BroadcastReceiver inside the Application class.

DeeplinkReceiver deeplinkReceiver = new DeeplinkReceiver();
        IntentFilter filter = new IntentFilter("com.smartech.EVENT_PN_INBOX_CLICK");
        context.registerReceiver(deeplinkReceiver, filter);
val deeplinkReceiver = DeeplinkReceiver()
        val filter = IntentFilter("com.smartech.EVENT_PN_INBOX_CLICK")
        registerReceiver(deeplinkReceiver, filter)

Write the following code in the onCreate function of the launcher activity of your application.

new DeeplinkReceiver().onReceive(this, getIntent())
DeeplinkReceiver().onReceive(this, intent)

Step 7: Customizing Notification Appearance

We have created SMTNotificationOptions to provide you the functionality to change your Notifications icons, brand logo, and color. You can create an object of this class to set the notifications icon, color, etc., and apply these changes using setNotificationOptions() methods that take SMTNotificationOptions object as a parameter.

Add the given snippet inside the onCreate() method of the Application Class​​ to set brand logo, large icon, small icon, transparent icon and icon color for your notifications.

📘

If you are using Android CEE Push SDK 3.2.7 and above, please follow below steps:

SMTNotificationOptions options = new SMTNotificationOptions(this);
options.setBrandLogo("logo"); //e.g.logo is sample name for brand logo
options.setLargeIcon("icon_nofification");//e.g.ic_notification is sample name for large icon
options.setSmallIcon("ic_action_play"); //e.g.ic_action_play is sample name for icon
options.setSmallIconTransparent("ic_action_play"); //e.g.ic_action_play is sample name for transparent small icon
options.setTransparentIconBgColor("#FF0000");
options.setPlaceHolderIcon("ic_notification");//e.g.ic_notification is sample name for placeholder icon
SmartPush.getInstance(new WeakReference(context)).setNotificationOptions(options);
val options = SMTNotificationOptions(context)
options.brandLogo = "logo"//e.g.logo is sample name for brand logo
options.largeIcon = "icon_nofification"//e.g.ic_notification is sample name for large icon
options.smallIcon = "ic_action_play"//e.g.ic_action_play is sample name for icon
options.smallIconTransparent = "ic_action_play"//e.g.ic_action_play is sample name for transparent small icon
options.transparentIconBgColor = "#FF0000"
options.placeHolderIcon = "ic_notification"//e.g.ic_notification is sample name for placeholder icon
SmartPush.getInstance(WeakReference(context)).setNotificationOptions(options)

🚧

If you are using Android CEE Push SDK 3.2.6 and below, please use below steps:

SMTNotificationOptions options = new SMTNotificationOptions(context);
options.setBrandLogoId(R.drawable.logo);
options.setLargeIconId(R.drawable.icon_nofification);
options.setSmallIconId(R.drawable.ic_action_play);
options.setSmallIconTransparentId(R.drawable.ic_action_play);
options.setTransparentIconBgColor("#FF0000");
options.setPlaceHolderIcon(R.drawable.ic_notification);
SmartPush.getInstance(new WeakReference(context)).setNotificationOptions(options);
val options = SMTNotificationOptions(context)
options.brandLogo = R.drawable.ic_notif
options.largeIcon = R.drawable.icon_nofification
options.smallIcon = R.drawable.ic_notif
options.smallIconTransparent = R.drawable.ic_notif
options.transparentIconBgColor = "#FF0000"
options.placeHolderIcon = R.drawable.ic_notification
SmartPush.getInstance(WeakReference(context)).setNotificationOptions(options)

Note:
The notification icon being used should strictly be in .png format as per Google’s UI guidelines​. Preferable size for the push notification icons is mentioned below.

drawable-mdpi       :   24 x 24
drawable-hdpi       :   36 x 36 
drawable-xhdpi      :   48 x 48
drawable-xxhdpi     :   72 x 72
drawable-xxxhdpi    :   96 x 96

🚧

Though we encourage SDK versions greater than 3.2.x, those currently on 3.1.x should continue to use "Smartech" rather than "SmartPush."


Did this page help you?