These docs are for v1.0. Click to read the latest docs for v2.0.

Push Notification

Render notification using Netcore SDK

Once you are done with the FCM setup, call the notification rendering method inside your FirebaseMessagingService.

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onNewToken(String token) {
        NetcoreSDK.setPushToken(context, token);
    }
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
         boolean pushFromSmartech = NetcoreSDK.handleNotification(getApplicationContext(), remoteMessage.getData());
      if(!pushFromSmartech){
        //Handle the notification received from other sources
      }
    }
}

Fetch Custom Payload and Deeplink on click of Notification

You can set custom key-value pairs and deeplink for your notification. In order to fetch this custom payload data and deeplink from push notification, add given snippet in the activity which is provided in deeplink.

Bundle bundle = getIntent().getExtras();
JSONObject jsonObject = new JSONObject(bundle.getString(“customPayload”));
String deeplink = bundle.getString(“deeplink”);

If you want to know how to send Custom Key Value pairs in push notification from Smartech panel - read more out it here.

Custom Push Notification Icon

With the launch of Android 5 (Lollipop), the notification icons are rendered differently in the notification bar at the top. By default, Smartech SDK uses the app’s icon for both the small icon as well as the large icon.

If you want to set a custom notification icon, add the following meta data entry in your AndroidManifest.xml.

<!--For Small icon :	-->
<meta-data  
	android:name="SMT_SMALL_NOTIFICATION_ICON"  
	android:value="<small_notification_icon_name>"/>

 <!--For Large icon (Optional): -->
<meta-data  
	android:name="SMT_LARGE_NOTIFICATION_ICON"  
	android:value="<large_notification_icon_name>"/>

📘

  1. notification_icon_name is the name of your file in the drawable directory without the file extension.
  2. The notification icon being used should strictly be in .png transparent format as per Google’s UI guidelines​.
  3. The method NetcoreSDK.setPushIcon() is deprecated from SDK v1.2.8.

Changing Push Notification Icon Color

To change the color of notification icon, add given snippet inside the onCreate() method of the Application Class​​.

NetcoreSDK.setPushIconColor(context, <argb>);

// Sample code for reference purpose only  
NetcoreSDK.setPushIconColor(context, Color.RED);

// If you are applying color from resource file.
NetcoreSDK.setPushIconColor(context, ContextCompat.getColor(context, R.color.colorName));

Reset Push Notification Icon Color

To reset the color of notification icon, add the given snippet.

NetcoreSDK.resetPushIconColor(context);