-
Notifications
You must be signed in to change notification settings - Fork 17
How to retrieve a message in my Activity when user taps on a notification?
Olga Koroleva edited this page Mar 11, 2021
·
2 revisions
In order to retrieve a message inside your activity, you will first have to provide your activity to the library (only if you want to use a non-default activity), and then you will have to handle the intent from the library.
When user taps on a library-generated notification, library will open the default launcher activity of your application. If you want any other activity to be opened on notification tap, then you can provide a callback activity via notification settings:
MobileMessaging.Builder(application)
.withDisplayNotification(NotificationSettings.Builder(application)
.withCallbackActivity(MyActivity::class.java)
.build())
.build()
expand to see Java code
new MobileMessaging.Builder(getApplication())
.withDisplayNotification(new NotificationSettings.Builder(getApplication())
.withCallbackActivity(MyActivity.class)
.build())
.build();
In order to receive message inside your Activity, you should also override onNewIntent method:
class MyActivity: Activity() {
...
override fun onNewIntent(intent: Intent) {
val message = Message.createFrom(intent.getBundleExtra(BroadcastParameter.EXTRA_MESSAGE))
}
...
}
expand to see Java code
public class MyActivity extends Activity {
...
@Override
protected void onNewIntent(Intent intent) {
Message message = Message.createFrom(intent.getBundleExtra(BroadcastParameter.EXTRA_MESSAGE));
}
...
}
If you have any questions or suggestions, feel free to send an email to [email protected] 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