Notification Service
SDK provide APIs to subscribe for push notification using FCM or XMPP notification over websocket using SDK callback. Before invoking notification APIs, make sure you have initialized the SDK and set the mandatory configuration as mentioned here.
XMPP Notification
To use XMPP notification (Instead of FCM), use onNotification callback method. The client needs to be connected to 555 backend by intializing the SDK and setting the configurations to avail this notification callback.
To use this you need to implement Rtc555SdkObserver interface and initialize the notification observer with setNotificationObserver(Rtc555SdkObserver).
Rtc555Sdk.setNotificationObserver(this);
FCM Notification
Create Subscriptions
This API will register the subscriber for the PUSH notification and create subscription for topic provided. On success, a Subscriber-Id will be generated for this device-user combination and returned. Implement Rtc555Ntm.Rtc555NtmObserver interface for callbacks.
Rtc555SubscriptionObject sub = new Rtc555SubscriptionObject();
sub.deviceToken = <deviceToken>;
sub.protocolType = Rtc555SubscriptionObject.ProtocolMode.FCM;
sub.topic = "federation/pstn/<Routing Id>";
ArrayList<Rtc555SubscriptionObject> subscriptions = new ArrayList<>();
subscriptions.add(sub);
Rtc555Ntm.createSubscriptions(subscriptions,<appDomain_String>,Rtc555NtmObserver)
Parameters | Type | Description |
---|---|---|
subscriptions | Array of type Rtc555SubscriptionObject | Each Subscription contains Device token, protocol and topic |
appDomain | string | app domain |
rtcNtmObserver | Rtc555NtmObserver | Callbacks |
Below is the Rtc555SubscriptionObject object that needs to be built:
Parameters | Type | Description |
---|---|---|
deviceToken | string | FCM device token |
protocolType | Rtc555SubscriptionObject.ProtocolMode | pass "fcm" based on the type of notification required |
topic | string | pass "federation/pstn/ |
Delete Subscription
Users need to pass subscriberId, topic and app domain for deleting subscription. Implement Rtc555Ntm.Rtc555NtmObserver interface for callbacks.
Rtc555Ntm.deleteSubscription(subscriberId, topic, appDomain,Rtc555NtmObserver);
Parameters | Type | Description |
---|---|---|
subscriberId | string | subscriber Id received from onSubscriptionSuccess callback |
Topic | Rtc555SubscriptionObject.Topic | subscribed topic |
appDomain | string | app domain |
Delete All Subscriptions
Users need to pass subscriberId for deleting all subscription. Implement Rtc555Ntm.Rtc555NtmObserver interface for callbacks.
Rtc555Ntm.deleteAllSubscriptions(subscriberId,Rtc555NtmObserver)
Parameters | Type | Description |
---|---|---|
subscriberId | string | subscriber Id received from onSubscriptionSuccess callback |
Notification Callbacks
onSubscriptionSuccess
This callback gets invoked when we receive success status for create subscription API.
void onSubscriptionSuccess(JSONArray subscriptionInfo) {
}
Parameters | Type | Description |
---|---|---|
subscriptionInfo | JSONArray | Each element in the array contains JSON of subscriberId , topic and protocol |
Below is the subscriptionInfo object details:
Parameters | Type | Description |
---|---|---|
subscriberId | string | subscriber Id |
topic | array | Array of subscribed topics |
protocol | string | fcm |
onSubscriptionFailure
This callback gets invoked when we receive error status for create subscription API.
public void onSubscriptionFailure(Rtc555Exception e) {
}
Parameters | Description |
---|---|
Rtc555Exception | Exception consists of error code and error message |
onSubscriptionDeleted
This callback gets invoked when we receive success status for delete subscription API.
public void onSubscriptionDeleted(String subscriberId, String topic) {
}
Parameters | Type | Description |
---|---|---|
subscriberId | string | subscriber Id |
topic | string | subscribed topic |
onSubscriptionDeletionFailure
This callback gets invoked when we receive error status for delete / delete all subscription API.
public void onSubscriptionDeletionFailure(Rtc555Exception e) {
}
Parameters | Description |
---|---|
Rtc555Exception | Exception consists of error code and error message |
onSubscriberDeleted
This callback gets invoked when we receive success status for delete all subscription API.
public void onSubscriberDeleted(String subscriberId) {
}
Parameters | Description |
---|---|
subscriberId | subscriber Id |