-
Notifications
You must be signed in to change notification settings - Fork 16
Library events
Events are intended to be used in BroadcastReceiver registered locally or at the application level.
You can register receivers at the application level by adding specific event to intent filter to AndroidManifest.xml:
<receiver android:name=".MyMessageReceiver" android:exported="false">
<intent-filter>
<action android:name="org.infobip.mobile.messaging.MESSAGE_RECEIVED"/>
<!-- register here another event you want to receive updates from -->
</intent-filter>
</receiver>
or register receivers in you Activity by adding:
class MyActivity : AppCompatActivity() {
private var isReceiverRegistered = false
private val messageReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val message = Message.createFrom(intent.extras)
//... process your message here
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
registerReceiver()
}
override fun onResume() {
super.onResume()
registerReceiver()
}
override fun onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(messageReceiver)
isReceiverRegistered = false
super.onPause()
}
private fun registerReceiver() {
if (isReceiverRegistered) {
return
}
LocalBroadcastManager.getInstance(this).registerReceiver(messageReceiver,
IntentFilter(Event.MESSAGE_RECEIVED.key))
isReceiverRegistered = true
}
}
expand to see Java code
public class MyActivity extends AppCompatActivity {
private boolean isReceiverRegistered;
private BroadcastReceiver messageReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Message message = Message.createFrom(intent.getExtras());
//... process your message here
}
};
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerReceiver();
}
protected void onResume() {
super.onResume();
registerReceiver();
}
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(messageReceiver);
isReceiverRegistered = false;
super.onPause();
}
private void registerReceiver() {
if (isReceiverRegistered) {
return;
}
LocalBroadcastManager.getInstance(this).registerReceiver(messageReceiver,
new IntentFilter(Event.MESSAGE_RECEIVED.getKey()));
isReceiverRegistered = true;
}
}
Library informs you about following events using Event (core module) class:
Event name | Description |
---|---|
TOKEN_RECEIVED |
Triggered by core module when cloud token is received (invoked each time library checks for token changes). Contains the cloud registration token. |
REGISTRATION_CREATED |
Triggered by core module when cloud registration token successfully stored on the registration server and the registration is created on a server. |
INSTALLATION_UPDATED |
Triggered by core module when installation is updated on a server. |
MESSAGE_RECEIVED |
Triggered by core module when message is received. Contains the received message information. |
MESSAGES_SENT |
Triggered by core module when messages are sent to MO service. Contains information and about each sent message. |
API_COMMUNICATION_ERROR |
Triggered by core module on every error returned by API. Contains the exception information. |
DELIVERY_REPORTS_SENT |
Triggered by core module when message delivery is reported. Contains the list of all reported message IDs. |
SEEN_REPORTS_SENT |
Triggered by core module when message seen is reported. Contains the list of all reported message IDs. |
NOTIFICATION_TAPPED |
Triggered by core module when notification is tapped. |
NOTIFICATION_DISPLAYED |
Triggered by core module when notification is displayed. Silent notifications will never be displayed. |
GOOGLE_PLAY_SERVICES_ERROR |
Triggered when google play services are unavailable on the device. |
USER_UPDATED |
Triggered when user data is updated on the server. |
PERSONALIZED |
Triggered when installation is successfully personalized on a server. |
DEPERSONALIZED |
Triggered when installation is depersonalized. |
Following interactive events are being reported using InteractiveEvent (interactive module) class:
InteractiveEvent name | Description |
---|---|
NOTIFICATION_ACTION_TAPPED |
Triggered by core module when notification action is tapped. |
MODAL_IN_APP_NOTIFICATION_IS_READY_TO_DISPLAY |
Triggered by core module when modal in-app notification is ready to be shown. |
Geofencing feature is DEPRECATED and not supported from SDK version 13.0.3 onwards.
Following geo events are being reported using GeoEvent (geo module) class:
GeoEvent name | Description |
---|---|
GEOFENCE_AREA_ENTERED |
Triggered by geo module when monitored geo area is entered. |
GEOFENCE_EVENTS_REPORTED |
Triggered by geo module when geofence events are reported to the server. |
Following chat events are being reported using Event (core module) class:
Event name | Parameters | Description |
---|---|---|
MESSAGE_RECEIVED |
Message.createFrom(intent) |
Triggered by chat module when the message is received by the SDK. |
NOTIFICATION_TAPPED |
Message.createFrom(intent) |
Triggered by chat module when notification for particular message is tapped by user. |
Action name to subscribe to: org.infobip.mobile.messaging.TOKEN_RECEIVED
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val cloudToken = intent.getStringExtra(BroadcastParameter.EXTRA_CLOUD_TOKEN)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
String cloudToken = intent.getStringExtra(BroadcastParameter.EXTRA_CLOUD_TOKEN);
}
Action name to subscribe to: org.infobip.mobile.messaging.REGISTRATION_CREATED
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context, intent: Intent) {
val pushRegistrationId = intent.getStringExtra(BroadcastParameter.EXTRA_INFOBIP_ID)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
String pushRegistrationId = intent.getStringExtra(BroadcastParameter.EXTRA_INFOBIP_ID);
}
Action name to subscribe to: org.infobip.mobile.messaging.INSTALLATION_UPDATED
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val installation = Installation.createFrom(intent.extras)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
Installation installation = Installation.createFrom(intent.getExtras());
}
Action name to subscribe to: org.infobip.mobile.messaging.MESSAGE_RECEIVED
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val message = Message.createFrom(intent.extras)
val customPayload: JSONObject = message.customPayload
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
Message message = Message.createFrom(intent.getExtras());
JSONObject customPayload = message.getCustomPayload();
}
Action name to subscribe to: org.infobip.mobile.messaging.MESSAGES_SENT
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val messages = Message.createFrom(intent.getParcelableArrayListExtra(BroadcastParameter.EXTRA_MESSAGES))
for (message in messages) {
// ... process message here
}
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
List<Message> messages = Message.createFrom(intent.<Bundle>getParcelableArrayListExtra(BroadcastParameter.EXTRA_MESSAGES));
for (Message message : messages) {
// ... process message here
}
}
Action name to subscribe to: org.infobip.mobile.messaging.API_COMMUNICATION_ERROR
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val mobileMessagingError = intent.getSerializableExtra(BroadcastParameter.EXTRA_EXCEPTION) as MobileMessagingError
val errorCode = mobileMessagingError.code
val errorMessage = mobileMessagingError.message
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
MobileMessagingError mobileMessagingError = (MobileMessagingError) intent.getSerializableExtra(BroadcastParameter.EXTRA_EXCEPTION);
String errorCode = mobileMessagingError.getCode();
String errorMessage = mobileMessagingError.getMessage();
}
Action name to subscribe to: org.infobip.mobile.messaging.DELIVERY_REPORTS_SENT
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val messageIDs = intent.getStringArrayExtra(BroadcastParameter.EXTRA_MESSAGE_IDS)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
String[] messageIDs = intent.getStringArrayExtra(BroadcastParameter.EXTRA_MESSAGE_IDS);
}
Action name to subscribe to: org.infobip.mobile.messaging.SEEN_REPORTS_SENT
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val messageIDs = intent.getStringArrayExtra(BroadcastParameter.EXTRA_MESSAGE_IDS)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
String[] messageIDs = intent.getStringArrayExtra(BroadcastParameter.EXTRA_MESSAGE_IDS);
}
Action name to subscribe to: org.infobip.mobile.messaging.GOOGLE_PLAY_SERVICES_ERROR
. Receiving event data in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val playServicesErrorCode = intent.getIntExtra(BroadcastParameter.EXTRA_PLAY_SERVICES_ERROR_CODE)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
int playServicesErrorCode = intent.getIntExtra(BroadcastParameter.EXTRA_PLAY_SERVICES_ERROR_CODE);
}
Action name to subscribe to: org.infobip.mobile.messaging.NOTIFICATION_DISPLAYED
. Receiving event bundle in BroadcastReceiver:
@Override
public void onReceive(Context context, Intent intent) {
Message message = Message.createFrom(intent.getExtras());
int notificationId = intent.getIntExtra(BroadcastParameter.EXTRA_NOTIFICATION_ID, BroadcastParameter.NOTIFICATION_NOT_DISPLAYED_ID);
}
Action name to subscribe to: org.infobip.mobile.messaging.NOTIFICATION_TAPPED
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val message = Message.createFrom(intent.extras)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
Message message = Message.createFrom(intent.getExtras());
}
Action name to subscribe to: org.infobip.mobile.messaging.interactive.NOTIFICATION_ACTION_TAPPED
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val message = Message.createFrom(intent.extras)
val notificationAction = NotificationAction.createFrom(intent.extras)
val notificationCategory = NotificationCategory.createFrom(intent.extras)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
Message message = Message.createFrom(intent.getExtras());
NotificationAction notificationAction = NotificationAction.createFrom(intent.getExtras());
NotificationCategory notificationCategory = NotificationCategory.createFrom(intent.getExtras());
}
Action name to subscribe to: org.infobip.mobile.messaging.interactive.MODAL_IN_APP_NOTIFICATION_IS_READY_TO_DISPLAY
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val message = Message.createFrom(intent.extras)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
Message message = Message.createFrom(intent.getExtras());
}
Action name to subscribe to: org.infobip.mobile.messaging.geo.GEOFENCE_AREA_ENTERED
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val geoMessage = GeoMessage.createFrom(intent.extras)
val geo = geoMessage.geo
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
GeoMessage geoMessage = GeoMessage.createFrom(intent.getExtras());
Geo geo = geoMessage.getGeo();
}
Action name to subscribe to: org.infobip.mobile.messaging.geo.GEOFENCE_EVENTS_REPORTED
. Receiving event bundle in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val geoReports = GeoReport.createFrom(intent.extras)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
List<GeoReport> geoReports = GeoReport.createFrom(intent.getExtras());
}
Action name to subscribe to: org.infobip.mobile.messaging.USER_UPDATED
. Receiving event data in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val user = User.createFrom(intent.extras)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
User user = User.createFrom(intent.getExtras());
}
Action name to subscribe to: org.infobip.mobile.messaging.PERSONALIZED
. Receiving event data in BroadcastReceiver:
override fun onReceive(context: Context?, intent: Intent) {
val user = User.createFrom(intent.extras)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
User user = User.createFrom(intent.getExtras());
}
Action name to subscribe to: org.infobip.mobile.messaging.DEPERSONALIZED
. Receiving event data in BroadcastReceiver:
override fun onReceive(context: Context, intent: Intent) {
val user = User.createFrom(intent.extras)
}
expand to see Java code
@Override
public void onReceive(Context context, Intent intent) {
User user = User.createFrom(intent.getExtras());
}
If you have any questions or suggestions, feel free to send an email to support@infobip.com or create an issue.
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
Geofencing API- DEPRECATED- Android Manifest components
- Privacy settings
- In-app chat
- Infobip RTC calls and UI
- Backup rules