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

Push Notification

Get FCM Token

To obtain the FCM token of the user from the SDK, add given snippet as per the requirement.

NetcoreSDK.getPushToken()
    .then(value => {
   	//Grab the value
    }).catch(reason => console.log(reason));

Custom Push Notification Icon (from SDK v1.2.8)

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.

To set a custom notification icon, add the following meta data entry in your AndroidManifest.xml.

<meta-data  
	android:name="SMT_LARGE_NOTIFICATION_ICON"  
	android:value="<large_notification_icon_name>"/> 
	
<meta-data  
	android:name="SMT_SMALL_NOTIFICATION_ICON"  
	android:value="<small_notification_icon_name>"/>

Note:

  1. notification_icon_name is the name of your file in the drawable directory without the file extension.
  2. The method NetcoreSDK.setPushIcon() is deprecated from SDK v1.2.8.
  3. 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

Changing Push Notification Icon Color (from SDK v1.2.8)

To change the colour 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 (from SDK v1.2.8)

To reset the colour of notification icon, add the given snippet in the activity.

NetcoreSDK.resetPushIconColor(context);

Fetch Delivered Push Notifications

To fetch delivered push notifications, add given snippet.

📘

NOTE :

The method returns a JSON of delivered push notifications for the user. ​

For Android:

NetcoreSDK.getNotifications(<count>)
    .then(value => {
   	//Grab the json data
   	value = JSON.stringify(value);
    }).catch(reason => console.log(reason));

For iOS:

NetcoreSDK.getNotificationsiOS(value => {
//Your code here
})

Fetch Unread Push Notification Count

To fetch unread push notification count from the NetcoreSDK, add given snippet as per the requirement.

NetcoreSDK.getUnreadNotificationsCount()
    .then(value => {
   	//Grab the value
    }).catch(reason => console.log(reason));

To Handle Custom Payload

To fetch custom payload data from the push notifications, add given snippet in the activity of the application as per the requirement.

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