You will learn how to track installs, daily visits, daily unique visitors and returning users using
BuzzBox Analytics SDK and how to run a background process to remind your users to use your App!
The analytics will also tell you the click through rate of your notifications.
Index: 1. Create the Task - 2. Start the Scheduler - 3. Download the source code
1. Create your background Task
public class ReminderTask implements Task { @Override public String getTitle() { return "Reminder"; } @Override public String getId() { return "reminder"; // give it an ID } @Override public TaskResult doWork(ContextWrapper ctx) { TaskResult res = new TaskResult(); // TODO implement your business logic here // i.e. query the DB, connect to a web service using HttpUtils, etc.. NotificationMessage notification = new NotificationMessage( "Hello World", "Don't forget to open Hello World App"); notification.notificationIconResource = R.drawable.icon_notification_cards_clubs; notification.setNotificationClickIntentClass(HelloWorldActivity.class); res.addMessage( notification ); return res; } }
2. Add the following code to the onCreate method of your main Activity
// 1. call BuzzBox Analytics
int openAppStatus = AnalyticsManager.onOpenApp(this);
// 2. add the Task to the Scheduler
if (openAppStatus==AnalyticsManager.OPEN_APP_FIRST_TIME) {
// register the Task when the App in installed
SchedulerManager.getInstance().saveTask(this,
"0 8-20/4 * * 1,2,3,4,5", // a cron string
ReminderTask.class);
SchedulerManager.getInstance().restart(this, ReminderTask.class );
} else if (openAppStatus==AnalyticsManager.OPEN_APP_UPGRADE){
// restart on upgrade
SchedulerManager.getInstance().restartAll(this, 0);
}
Your Task will run every 4 hour, from 8am to 8pm, Monday - Friday, according to the cron string 0 8-20/4 * * 1,2,3,4,5
Note: HelloWorldActivity is the Activity you want to run when the user click on the Notification
3. Download the entire App source code from here (zip)
Or take a look at the main files:
Proceed with reading the Quick Start Tutorial for a real case step-by-step integration tutorial.