Notifications

Foreword

Push notifications notify the user of new events in an application. Push notifications are generally created when information is sent by the server in communication with the application.

Tagging example

To tag push notifications, it’s necessary to have an IntentService class. This class will retrieve information from the server for generation of the application’s push notifications. Thanks to this, parameters can be added to the notification.

NB: In order to tag the deletion of a notification, you have to create a specific BroadcastReceiver

In AndroidManifest.xml:

1

2

3

4

5

6

<receiver

android:name=".DismissNotificationReceiver"

android:exported="true">

</receiver>

In DismissNotificationReceiver.java:

Java

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

packagecom.atinternet;

importandroid.content.BroadcastReceiver;

importandroid.content.Context;

importandroid.content.Intent;

importcom.atinternet.tracker.Tracker;

importjava.util.HashMap;

publicclassDismissNotificationReceiverextendsBroadcastReceiver{

@Override

publicvoidonReceive(Context context,Intent intent){

// Track Dismiss notification

Trackert=newTracker(context,newHashMap<String,Object>(){

{

put("log","YOURLOG");

put("logSSL","YOURSSLLOG");

put("site","YOURSITEID");

}

});

t.Screens().add("DismissNotification").sendView();

}

}

In the view called during the click on the push notification, it is now possible to retrieve information contained in the notification and therefore tag it.

Example:
We retrieve the notification’s Intent and we verify that the desired data exists:

Java

1

2

3

4

5

6

7

Tracker tracker=ATInternet.getInstance().getDefaultTracker();

if(getIntent().getStringExtra("xto")!=null){

tracker.Campaigns().add(getIntent().getStringExtra("xto"));

tracker.Screens().add("PushNotification").sendView();

}

If you wish to simplify the tagging of your links without having to know the significance of each field, try the interface available in our marketplace. Please note that this interface has been created by our community and can be improved, so feel free to send us your feedback!