Skip to content

Add a Notification Management Screen

We believe that empowering your end users with the ability to decide which notifications are relevant for them is one of the key elements that maintains an engaged audience, preventing end users from opting out of push notifications altogether.

For this purpose, you can assign your notification templates to groups called "Categories". These categories are then displayed to your end users in a native view that allows them to easily opt in and out of each category.

We have created a notification management view you can easily add to your application. Below is an example of how to add an Activity that shows the user their notification preferences and allows them to change these preferences.

Adding the View

  1. Create an activity layout

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:sendman="http://schemas.android.com/apk/res-auto"
        tools:context=".NotificationManagementActivity">
    
        <io.sendman.sendman.views.SendManNotificationsView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            sendman:switchOnThumbColor="@color/colorPrimary"
            sendman:switchOnTrackColor="@color/colorPrimary"
            />
    
    </androidx.constraintlayout.widget.ConstraintLayout>
    
    This activity layout uses SendManNotificationsView, which shows the current user's preferences (which default to your definitions as they are defined in the console ).

    Tip

    You may have noticed that some of the visual properties of the view are configurable via XML (if you didn't, take a look at the highlighted rows above).
    You can configure the look and feel of the view to match your app's design if you want to, as explained at the end of this guide.

  2. Create an Activity that displays the layout

    class NotificationManagementActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activitiy_notification_management)
        }
    }
    
    public class NotificationManagementActivity extends AppCompatActivity {
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activitiy_notification_management);
        }
    }
    

Customizing the View

Should you choose to add some of your app's colors to the design of the management page, you can do this through the XML markup, using these attributes:

Property Description
backgroundColor The background color of the entire management view.
rowBackgroundColor The background color of each category row, containing the category's name, description, and the thumb.
switchOnTrackColor The background tint of a switch when the category is turned on. Should be supplied with its 'off' counterpart.
switchOffTrackColor The background tint of a switch when the category is turned off. Should be supplied with its 'on' counterpart.
switchOnThumbColor The thumb color of the switch when the category is turned on.
switchOffThumbColor The thumb color of the switch when the category is turned off.
titleColor The text color for category group names, placed above the rows of categories.
descriptionColor The text color of the category's description (or the category group's description, placed under the row).
textColor The text color for category names.