-jio-start-block-type-2
JioPushClientService
Jio Magnum SDK service will start the above JioPushClientService
upon notification received from broker.
import android.util.Log;
import com.jio.JioPushclient.JioPushIntentService;
import com.jio.JioPushclient.JioPushPayLoad;
public class JioPushClientService extends PushIntentService {
private static final String TAG = "JioPushClientService";
@Override
public void handlePushNotification(PushPayLoad JioPushPayLoad) {
String topic = JioPushPayLoad.getTopic();
String payload = JioPushPayLoad.getPayload();
int messageId = JioPushPayLoad.getMessageId();
int sourceId = JioPushPayload.getSourceId();
Log.d(TAG, "handleJIOPUSHPusNotification " + JioPushPayLoad);
NotificationHandler.getInstance().showNotification(getApplicationContext(),payload);
}
}
The app must override methods handleJioPushNotification() in order to handle status and notification callbacks.
-jio-style-title
Please follow the below Android API links to show the Notification and Badge. https://developer.android.com/reference/android/app/Notification.Builder
https://developer.android.com/reference/android/app/Notification.Builder.html#setNumber(int)
Notification notification = new NotificationCompat.Builder(MainActivity.this, CHANNEL_ID)
.setContentTitle("New Messages")
.setContentText("You've received 3 new messages.")
.setSmallIcon(R.drawable.ic_notify_status)
.setNumber(messageCount)
.build();
-jio-style-title
Below is the code snippet for reference.
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel pushLogNotiChannel = new NotificationChannel(
CHANNEL_ID,
"PushLog Service Channel",
NotificationManager.IMPORTANCE_DEFAULT
);
pushLogNotiChannel.setShowBadge(true);
NotificationManager manager = getSystemService(NotificationManager.class);
manager.createNotificationChannel(pushLogNotiChannel);
Notification notification = new Notification.Builder(this, CHANNEL_ID)
.setContentTitle("Content Title")
.setContentText("Content Text")
.setSmallIcon(R.drawable.ic_launcher_background)
.setNumber(4) // Notification count
.build();
startForeground(1, notification);
} else {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Content Title")
.setContentText("Content Text")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setNumber(4) // Notification count
.setAutoCancel(true);
Notification notification = builder.build();
startForeground(1, notification);
}
-jio-end-block-type-2