-
Notifications
You must be signed in to change notification settings - Fork 0
Notifications ed1d7f
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.
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.
Example of code for creating a notification containing information:
package com.atinternet.atinternetdemo;
import android.app.IntentService;
import android.content.Intent;
public class DemoService extends IntentService {
public DemoService(String name) {
super(name);
}
@Override
public void onCreate() {
super.onCreate();
}
@Override
protected void onHandleIntent(Intent intent) {
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle("MyNotification")
.setSmallIcon(android.R.drawable.ic_dialog_alert)
.setContentText("Notification received");
Intent notificationIntent = new Intent(getApplicationContext(), DestinationActivity.class);
notificationIntent.putExtra("xto", "AD-10");
PendingIntent intent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
notificationBuilder.setContentIntent(intent);
// Catch Delete Notification event
Intent deleteIntent = new Intent(this, DismissNotificationReceiver.class);
PendingIntent pendingDeleteIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, deleteIntent, 0);
notificationBuilder.setDeleteIntent(pendingDeleteIntent);
NotificationManager mNotifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mNotifyMgr.notify(0, notificationBuilder.build());
}
}This Intent will then be used by the notification.
NB: In order to tag the deletion of a notification, you have to create a specific BroadcastReceiver
In AndroidManifest.xml:
<receiver
android:name=".DismissNotificationReceiver"
android:exported="true">
</receiver>
In DismissNotificationReceiver.java:
package com.atinternet;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.atinternet.tracker.Tracker;
import java.util.HashMap;
public class DismissNotificationReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Track Dismiss notification
Tracker t = new Tracker(context, new HashMap<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:
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!
Last update: 18/05/2018
Developers » AS2 tagging » Android » Advanced features » Notifications
Navigation
Permalink
-
Data API
- Data flow
- Advice optimizations data flow
- Error codes data flow
- Faq data flow
- General information data flow
- Technical information data flow
- Reporting API v3
- Getting started
- Methods
- Parameters
- Technical information
- REST API
- Campaigns
- Custom variables
- Getting started rest
- Methods rest
- Response structure parameters rest
- Fixed periods
- Parameters compatibility
- Relative periods
- Structure of the response
- “code” parameter
- “columns” parameter
- “evo” parameter
- “filter” parameter
- “include” parameter
- “lng” parameter
- “max-results” parameter
- “page-num” parameter
- “period” parameter
- “period” parameter: “H” v. “He” & “MN” v. “MNe”
- “retention” parameter
- “segmentdesc” parameter
- “segment” parameter
- “sep” parameter
- “sort” parameter
- “space” parameter
- Technical specifications rest
- Data flow
-
Data collection
- Android
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Users
- Apple
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Users
- General
- Cddc renew staging process
- Changelog
- Craft your hit
- Encoded parameters
- Server side cookie management
- Supported taggings
- Tagging deletion
- Utilisation of dispatch sdks
- JavaScript
- Advanced features
- Campaigns
- Changelog
- Content
- Ecommerce
- Getting started
- Partners javascript
- Users
- Piano Analytics
- Event tagging piano analytics
- Getting started piano analytics
- Piano analytics tagging
- Feeding piano analytics with as2 tagging
- Tagging custom properties sdk
- Android