Push Notification
SDK Initilization
Handling Deeplink
To handle deeplink in Foreground, Background and Terminated state, add below code to listen for incoming value.
document.addEventListener("SmartechHandleDeeplink", (response) => {
var objData = JSON.parse(JSON.stringify(e));
var deeplink = objData.deeplink;
var customPayload = objData.customPayload;
});
Get FCM Token
To obtain the FCM token of the user from the SDK, add given snippet as per the requirement.
Smartech.getDevicePushToken(function(response){
//Grab the response
}, function(error){
});
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 given snippet inside the onCreate()
method of the Application Class
.
SMTNotificationOptions options = new SMTNotificationOptions(this);
options.setSmallIconTransparentId(R.drawable.ic_notif);
Smartech.getInstance(new 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
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
.
SMTNotificationOptions options = new SMTNotificationOptions(this);
options.setTransparentIconBgColor("#007AFF");
Smartech.getInstance(new WeakReference<>(context)).setNotificationOptions(options);
Updated almost 4 years ago