SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
 
 
 
 
 
 
 
 
Mixpanel Integration with Android
BrainBox Network. Copyright@2015. All rights reserved
 
 
The document provides steps to integrate Android with Mixpanel integration.
The integration process requires following steps ‐
1. Instructions
2. Create New Project
3. Dashboard Setup
4. Configuration of Project
5. Android Code Setup
6. Custom Notification
7. Send Image with Push Notification
8. Further Information
BrainBox Network. Copyright@2015. All rights reserved
 
 
INSTRUCTIONS 
 
 
 
➔ Please Follow these instructions:
➔ Create Google Account
➔ Open below given Url:
https://console.developers.google.com
➔ Click on “Select Project” dropdown.
BrainBox Network. Copyright@2015. All rights reserved
 
 
CREATE NEW PROJECT 
 
 
 
 
➔ Give name of new project in the “Project” field.
➔ Click on “Enable and Manage API” button.
➔ Enable these services by “Google Cloud Messaging”
➔ Click on “Credentials tag” (In the left side or below of overview)
➔ Click on “Create Credentials”
➔ Select “API key”
➔ Then select android key
➔ Select “+Add Package name and fingerprint”
➔ Enter your “Package name”
➔ Enter your “SHA‐1 Key”
1. Open CMD from your system Java bin directory
For Ex:​“C:Program Files (x86)Javajdk1.6.0bin”
2. Run following command in CMD
3. Keytool ‐list ‐v ‐keystore
"C:UsersAdmin.androiddebug.keystore"​(Mention your system path
till “debug.keystore” file)
4. ‐alias androiddebugkey ‐storepass android ‐keypass android
5. Hence SHA‐1 KEY will shown in output
6. After fill all information Select Create & Save android key in somewhere.
BrainBox Network. Copyright@2015. All rights reserved
 
 
 
 
 
➔ Again Click on “Create Credentials”
➔ Select “API key”
➔ Then select Server key
➔ Then click Create Button
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
➔ Open below link on browser
https://developers.google.com/mobile/add
➔ Pick a platform (Android / IOS)
➔ Select your App name
➔ Write your “Package name” in android package name box
➔ Select “CONTINUE TO Choose and configure service”
➔ Adding services which you wants
➔ For push notification enable cloud messaging
➔ Select continue to generate configuration files
 
 
 
 
 
 
 
BrainBox Network. Copyright@2015. All rights reserved
 
 
 
 
 
 
 
 
 
 
 
 
 
➔ Click on “Download google‐services.json”
➔ After downloading, copy the google‐services.json to the app/ or mobile/module directory in
your Android project
 
 
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
DASHBOARD SETUP 
 
➔ Open Mixpanel website and Create new account or Login 
➔ Click on “Create Project”
➔ Write your “Project name” then on “Create Project” button
➔ Click on “Create Project​” 
 
 
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
CONFIGURATION OF PROJECT 
 
➔ Click on Settings Icon, showing in the left bottom corner.
 
 
 
 
➔ Save Project Token, for use it further
 
 
 
BrainBox Network. Copyright@2015. All rights reserved
 
 
 
➔ Click on Notifications Icon
➔ Paste your Android GCM Service key
➔ Click on “Save Changes”
➔ Now click on “Close”
 
 
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
ANDROID CODE SETUP 
 
➔ Add dependencies to App/build.gradle:
Compile 'com.google.android.gms:play‐services:8.4.0'
Compile 'com.mixpanel.android:mixpanel‐android:4.8.0'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
BrainBox Network. Copyright@2015. All rights reserved
 
 
➔ Add permissions to app/src/main/AndroidManifest.xml
<uses‐permission android:name="android.permission.INTERNET" />
<uses‐permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses‐permission android:name="android.permission.GET_ACCOUNTS" />
<uses‐permission android:name="android.permission.WAKE_LOCK" />
<permission android:name=“<YOUR_APPLICATION_PACKAGE>.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses‐permission android:name="<YOUR_APPLICATION_PACKAGE>.permission.C2D_MESSAGE" />
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
➔ Paste below code in “Application” tag in manifest
<receiver android:name="com.mixpanel.android.mpmetrics.GCMReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent‐filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="YOUR_PACKAGE_NAME" />
</intent‐filter>
</receiver>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
BrainBox Network. Copyright@2015. All rights reserved
 
 
 
➔ Setup Java Code in App
MixpanelAPI mixpanel = MixpanelAPI.getInstance(this,<MIXPANEL TOKEN>");
mixpanel.identify(GENERATE DISTINCT ID);
MixpanelAPI.People people = mixpanel.getPeople();
people.identify(SET_USER_ID);
people.initPushHandling(GOOGLE_PROJECT_NUMBER);
people.showNotificationIfAvailable(this);
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
➔ Setup User Profile in Mixpanel
JSONObject messageProps = new JSONObject();
try {
messageProps.put("User Age","25");
} catch (JSONException e) {
e.printStackTrace();
}
mixpanel.registerSuperPropertiesOnce(messageProps);
OR
mixpanel.registerSuperProperties(messageProps);
 
 
 
 
 
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
➔ Set Super Properties
try {
final JSONObject userProfile = new JSONObject();
userProfile.put("$name" ,"TEST");
userProfile.put("$email" , "ABC@GMAIL.COM");
String timeStamp = new SimpleDateFormat("yyyy‐MM‐dd HH:mm:ss").format(new
Date());
userProfile.put("$created", timeStamp);
mixpanel.getPeople().set(userProfile);
} catch (JSONException e) {
e.printStackTrace();
}
 
 
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
➔ Tracking User Action
mixpanel.track(“EVENT_NAME");
WRITE BELOW CODE IN ACTIVITY
@Override
protected void onDestroy() {
super.onDestroy();
mixpanel.flush();
}
 
 
 
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
CUSTOM NOTIFICATION 
 
➔ CREATE OWN RECEIVER (For Ex. My Receiver) :
➔ Insert Below code in app/src/main/AndroidManifest.xml
<receiver
android:name=“.My Receiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent‐filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.google.android.gcm.demo.app"/>
</intent‐filter>
<intent‐filter>
<action android:name=“<GIVEN NAME (MYBROADCAST)>">
</action>
</intent‐filter>
</receiver>
 
 
 
 
 
 
 
 
 
 
 
 
 
BrainBox Network. Copyright@2015. All rights reserved
 
 
 
➔ MYRECEIVER.JAVA class CODE
public class MyReceiver extends BroadcastReceiver {
Context context;
@Override
public void onReceive(Context context, Intent intent) {
Bundle data = intent.getExtras();
String notificationMessage = data.getString("mp_message");
this.context=context;
if(data.containsKey("IMAGE_KEY"))
{
//NOTIFICATION WITH IMAGE
String image_url = data.getString("IMAGE_URL");
new DownloadImage().execute(image_url,notificationMessage);
}
else
{
//NOTIFICATION WITHOUT IMAGE
simpleNotification(notificationMessage);
}
}
public class DownloadImage extends AsyncTask<String,Void,Bitmap>
{
Bitmap message_bitmap = null;
@Override
protected Bitmap doInBackground(String... parms) {
try {
URL url = new URL(parms[0]);
HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
message_bitmap = BitmapFactory.decodeStream(input);
int icon = R.mipmap.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
String title = "<APP_TITLE>";
Intent notificationIntent = null;
notificationIntent = new Intent(Intent.ACTION_VIEW);
notificationIntent.addCategory(Intent.CATEGORY_BROWSABLE);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
BrainBox Network. Copyright@2015. All rights reserved
 
 
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent1 =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
Notification notification = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentText(parms[1])
.setContentIntent(intent1)
.setSmallIcon(icon)
.setWhen(when)
.setStyle(new
NotificationCompat.BigPictureStyle().bigPicture(message_bitmap))
.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
} catch (Exception e) {
e.printStackTrace();
}
return message_bitmap;
}
@Override
protected void onPostExecute(Bitmap aVoid) {
super.onPostExecute(aVoid);
}
}
public void simpleNotification(String message)
{
int icon = R.mipmap.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
String title = "<APP_TITLE>";
Intent notificationIntent = null;
notificationIntent = new Intent(Intent.ACTION_VIEW);
notificationIntent.addCategory(Intent.CATEGORY_BROWSABLE);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent1 =PendingIntent.getActivity(context, 0,
notificationIntent, 0);
Notification notification = new NotificationCompat.Builder(context)
.setContentTitle(title)
.setContentText(message)
.setContentIntent(intent1)
.setSmallIcon(icon)
.setWhen(when)
.build();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
}
BrainBox Network. Copyright@2015. All rights reserved
 
 
}
SEND IMAGE WITH PUSH NOTIFICATION FROM MIXPANEL 
DASHBOARD 
 
➔ Create Push Notification in Mixpanel
➔ Set Audience
➔ Set your Push Notification
➔ Set Custom data (Extra data)
➔ For Image send Image_key
For Eg: Image_key ‐> “12345”) and
Image_url ‐> “​http://tineye.com/images/widgets/mona.jpg​”
➔ In Custom data ‐> In Json form‐>Send
 
 
 
 
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
FOR FURTHER INFORMATION 
 
➔ https://mixpanel.com/help/reference/android
➔ https://github.com/mixpanel/mixpanel‐android
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   
BrainBox Network. Copyright@2015. All rights reserved
 
 
Thank You So Very Much
For queries please write on ​ashish@mobifly.in
Developed By
Mohit Saini
Android Developer ‐ Mobifly
mobifly.in
 
 
BrainBox Network. Copyright@2015. All rights reserved
 

Más contenido relacionado

La actualidad más candente

Building a Twitter App with Silverlight 3 - Part 2
Building a Twitter App with Silverlight 3 - Part 2Building a Twitter App with Silverlight 3 - Part 2
Building a Twitter App with Silverlight 3 - Part 2
Clint Edmonson
 
How-to Create a 'Lock' record in Salesforce
How-to Create a 'Lock' record in SalesforceHow-to Create a 'Lock' record in Salesforce
How-to Create a 'Lock' record in Salesforce
Saaspoint
 

La actualidad más candente (20)

Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch TutorialMongoDB.local Seattle 2019: MongoDB Stitch Tutorial
MongoDB.local Seattle 2019: MongoDB Stitch Tutorial
 
Mobile for SharePoint with Windows Phone
Mobile for SharePoint with Windows PhoneMobile for SharePoint with Windows Phone
Mobile for SharePoint with Windows Phone
 
TechEvent Advanced Service Worker / PWA with Google Workbox
TechEvent Advanced Service Worker / PWA with Google WorkboxTechEvent Advanced Service Worker / PWA with Google Workbox
TechEvent Advanced Service Worker / PWA with Google Workbox
 
I/O Rewind 215: What's new in Android
I/O Rewind 215: What's new in AndroidI/O Rewind 215: What's new in Android
I/O Rewind 215: What's new in Android
 
Android - Getting Started With Firebase Auth
Android - Getting Started With Firebase AuthAndroid - Getting Started With Firebase Auth
Android - Getting Started With Firebase Auth
 
Langkah-langkah Instalasi software untuk develop aplikasi android
Langkah-langkah Instalasi software untuk develop aplikasi androidLangkah-langkah Instalasi software untuk develop aplikasi android
Langkah-langkah Instalasi software untuk develop aplikasi android
 
Building a Twitter App with Silverlight 3 - Part 2
Building a Twitter App with Silverlight 3 - Part 2Building a Twitter App with Silverlight 3 - Part 2
Building a Twitter App with Silverlight 3 - Part 2
 
How to add your own OpenSocial Gadgets to IBM Connections
How to add your own OpenSocial Gadgets to IBM ConnectionsHow to add your own OpenSocial Gadgets to IBM Connections
How to add your own OpenSocial Gadgets to IBM Connections
 
Level up apps and websites with vue.js
Level up  apps and websites with vue.jsLevel up  apps and websites with vue.js
Level up apps and websites with vue.js
 
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
 
MongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch TutorialMongoDB.local Atlanta: MongoDB Stitch Tutorial
MongoDB.local Atlanta: MongoDB Stitch Tutorial
 
Urban Airship and Android Integration for Push Notification and In-App Notifi...
Urban Airship and Android Integration for Push Notification and In-App Notifi...Urban Airship and Android Integration for Push Notification and In-App Notifi...
Urban Airship and Android Integration for Push Notification and In-App Notifi...
 
Urban Airship & Android Application Integration Document
Urban Airship & Android Application Integration DocumentUrban Airship & Android Application Integration Document
Urban Airship & Android Application Integration Document
 
How to enhance Email with Embedded Experiences
How to enhance Email with Embedded ExperiencesHow to enhance Email with Embedded Experiences
How to enhance Email with Embedded Experiences
 
How-to Create a 'Lock' record in Salesforce
How-to Create a 'Lock' record in SalesforceHow-to Create a 'Lock' record in Salesforce
How-to Create a 'Lock' record in Salesforce
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
NetWeaver Developer Studio for New-Beas
NetWeaver Developer Studio for New-BeasNetWeaver Developer Studio for New-Beas
NetWeaver Developer Studio for New-Beas
 
Creating Openbravo Workspace Widgets
Creating Openbravo Workspace WidgetsCreating Openbravo Workspace Widgets
Creating Openbravo Workspace Widgets
 
Google+ API (2012)
Google+ API (2012)Google+ API (2012)
Google+ API (2012)
 

Destacado (10)

R.j.509 ana 2013
R.j.509 ana 2013R.j.509 ana 2013
R.j.509 ana 2013
 
Ryan_Resume (6)
Ryan_Resume (6)Ryan_Resume (6)
Ryan_Resume (6)
 
Educacion
EducacionEducacion
Educacion
 
Calendario 3ª División G12 Temp 2012-2013
Calendario 3ª División G12 Temp 2012-2013Calendario 3ª División G12 Temp 2012-2013
Calendario 3ª División G12 Temp 2012-2013
 
Vishal Kataria_CV
Vishal Kataria_CVVishal Kataria_CV
Vishal Kataria_CV
 
Luis aguilar
Luis aguilarLuis aguilar
Luis aguilar
 
Yates presentation
Yates presentationYates presentation
Yates presentation
 
Biochemical case study
Biochemical case studyBiochemical case study
Biochemical case study
 
Data Breaches: Electronic Medical Records
Data Breaches: Electronic Medical RecordsData Breaches: Electronic Medical Records
Data Breaches: Electronic Medical Records
 
Presentation by Astrid Dininno
Presentation by Astrid DininnoPresentation by Astrid Dininno
Presentation by Astrid Dininno
 

Similar a Mixpanel Integration in Android

Google external login setup in ASP (1).pdf
Google external login setup in ASP  (1).pdfGoogle external login setup in ASP  (1).pdf
Google external login setup in ASP (1).pdf
findandsolve .com
 
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
DataLeader.io
 
Full screen Web Browser support RS-232 / TCPIP peripheral (plugin)
Full screen Web Browser support RS-232 / TCPIP peripheral (plugin)Full screen Web Browser support RS-232 / TCPIP peripheral (plugin)
Full screen Web Browser support RS-232 / TCPIP peripheral (plugin)
topomax
 
Magento 2 Cloud Backup
Magento 2 Cloud BackupMagento 2 Cloud Backup
Magento 2 Cloud Backup
Meetanshi
 
Google Cloud Messaging
Google Cloud MessagingGoogle Cloud Messaging
Google Cloud Messaging
Ashiq Uz Zoha
 
TTN things connected acount creation
TTN things connected acount creationTTN things connected acount creation
TTN things connected acount creation
Jisc
 

Similar a Mixpanel Integration in Android (20)

Jenkins Setup Document
Jenkins Setup DocumentJenkins Setup Document
Jenkins Setup Document
 
Steps how to create active x using visual studio 2008
Steps how to create active x using visual studio 2008Steps how to create active x using visual studio 2008
Steps how to create active x using visual studio 2008
 
Homestead Weather workshop
Homestead Weather workshopHomestead Weather workshop
Homestead Weather workshop
 
Android Froyo
Android FroyoAndroid Froyo
Android Froyo
 
Google external login setup in ASP (1).pdf
Google external login setup in ASP  (1).pdfGoogle external login setup in ASP  (1).pdf
Google external login setup in ASP (1).pdf
 
Raspberry pi and Google Cloud
Raspberry pi and Google CloudRaspberry pi and Google Cloud
Raspberry pi and Google Cloud
 
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
 
Jenkins CI/CD setup for iOS in Mac OSX
Jenkins CI/CD setup for iOS in Mac OSXJenkins CI/CD setup for iOS in Mac OSX
Jenkins CI/CD setup for iOS in Mac OSX
 
Full screen Web Browser support RS-232 / TCPIP peripheral (plugin)
Full screen Web Browser support RS-232 / TCPIP peripheral (plugin)Full screen Web Browser support RS-232 / TCPIP peripheral (plugin)
Full screen Web Browser support RS-232 / TCPIP peripheral (plugin)
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspective
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Magento 2 Cloud Backup
Magento 2 Cloud BackupMagento 2 Cloud Backup
Magento 2 Cloud Backup
 
AI: Mobile Apps That Understands Your Intention When You Typed
AI: Mobile Apps That Understands Your Intention When You TypedAI: Mobile Apps That Understands Your Intention When You Typed
AI: Mobile Apps That Understands Your Intention When You Typed
 
TDC2016SP - Trilha Android
TDC2016SP - Trilha AndroidTDC2016SP - Trilha Android
TDC2016SP - Trilha Android
 
Google Cloud Messaging
Google Cloud MessagingGoogle Cloud Messaging
Google Cloud Messaging
 
Converting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile CloudConverting Your Mobile App to the Mobile Cloud
Converting Your Mobile App to the Mobile Cloud
 
M365 global developer bootcamp 2019 PA
M365 global developer bootcamp 2019  PAM365 global developer bootcamp 2019  PA
M365 global developer bootcamp 2019 PA
 
A (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project FilesA (very) opinionated guide to MSBuild and Project Files
A (very) opinionated guide to MSBuild and Project Files
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
TTN things connected acount creation
TTN things connected acount creationTTN things connected acount creation
TTN things connected acount creation
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Mixpanel Integration in Android

  • 1.                 Mixpanel Integration with Android BrainBox Network. Copyright@2015. All rights reserved  
  • 2.   The document provides steps to integrate Android with Mixpanel integration. The integration process requires following steps ‐ 1. Instructions 2. Create New Project 3. Dashboard Setup 4. Configuration of Project 5. Android Code Setup 6. Custom Notification 7. Send Image with Push Notification 8. Further Information BrainBox Network. Copyright@2015. All rights reserved  
  • 3.   INSTRUCTIONS        ➔ Please Follow these instructions: ➔ Create Google Account ➔ Open below given Url: https://console.developers.google.com ➔ Click on “Select Project” dropdown. BrainBox Network. Copyright@2015. All rights reserved  
  • 4.   CREATE NEW PROJECT          ➔ Give name of new project in the “Project” field. ➔ Click on “Enable and Manage API” button. ➔ Enable these services by “Google Cloud Messaging” ➔ Click on “Credentials tag” (In the left side or below of overview) ➔ Click on “Create Credentials” ➔ Select “API key” ➔ Then select android key ➔ Select “+Add Package name and fingerprint” ➔ Enter your “Package name” ➔ Enter your “SHA‐1 Key” 1. Open CMD from your system Java bin directory For Ex:​“C:Program Files (x86)Javajdk1.6.0bin” 2. Run following command in CMD 3. Keytool ‐list ‐v ‐keystore "C:UsersAdmin.androiddebug.keystore"​(Mention your system path till “debug.keystore” file) 4. ‐alias androiddebugkey ‐storepass android ‐keypass android 5. Hence SHA‐1 KEY will shown in output 6. After fill all information Select Create & Save android key in somewhere. BrainBox Network. Copyright@2015. All rights reserved  
  • 5.         ➔ Again Click on “Create Credentials” ➔ Select “API key” ➔ Then select Server key ➔ Then click Create Button           BrainBox Network. Copyright@2015. All rights reserved  
  • 6.   ➔ Open below link on browser https://developers.google.com/mobile/add ➔ Pick a platform (Android / IOS) ➔ Select your App name ➔ Write your “Package name” in android package name box ➔ Select “CONTINUE TO Choose and configure service” ➔ Adding services which you wants ➔ For push notification enable cloud messaging ➔ Select continue to generate configuration files               BrainBox Network. Copyright@2015. All rights reserved  
  • 7.                         ➔ Click on “Download google‐services.json” ➔ After downloading, copy the google‐services.json to the app/ or mobile/module directory in your Android project                 BrainBox Network. Copyright@2015. All rights reserved  
  • 8.   DASHBOARD SETUP    ➔ Open Mixpanel website and Create new account or Login  ➔ Click on “Create Project” ➔ Write your “Project name” then on “Create Project” button ➔ Click on “Create Project​”                  BrainBox Network. Copyright@2015. All rights reserved  
  • 9.   CONFIGURATION OF PROJECT    ➔ Click on Settings Icon, showing in the left bottom corner.         ➔ Save Project Token, for use it further       BrainBox Network. Copyright@2015. All rights reserved  
  • 10.     ➔ Click on Notifications Icon ➔ Paste your Android GCM Service key ➔ Click on “Save Changes” ➔ Now click on “Close”                 BrainBox Network. Copyright@2015. All rights reserved  
  • 11.   ANDROID CODE SETUP    ➔ Add dependencies to App/build.gradle: Compile 'com.google.android.gms:play‐services:8.4.0' Compile 'com.mixpanel.android:mixpanel‐android:4.8.0'                                         BrainBox Network. Copyright@2015. All rights reserved  
  • 12.   ➔ Add permissions to app/src/main/AndroidManifest.xml <uses‐permission android:name="android.permission.INTERNET" /> <uses‐permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses‐permission android:name="android.permission.GET_ACCOUNTS" /> <uses‐permission android:name="android.permission.WAKE_LOCK" /> <permission android:name=“<YOUR_APPLICATION_PACKAGE>.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses‐permission android:name="<YOUR_APPLICATION_PACKAGE>.permission.C2D_MESSAGE" />             BrainBox Network. Copyright@2015. All rights reserved  
  • 13.   ➔ Paste below code in “Application” tag in manifest <receiver android:name="com.mixpanel.android.mpmetrics.GCMReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent‐filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="YOUR_PACKAGE_NAME" /> </intent‐filter> </receiver>                                     BrainBox Network. Copyright@2015. All rights reserved  
  • 14.     ➔ Setup Java Code in App MixpanelAPI mixpanel = MixpanelAPI.getInstance(this,<MIXPANEL TOKEN>"); mixpanel.identify(GENERATE DISTINCT ID); MixpanelAPI.People people = mixpanel.getPeople(); people.identify(SET_USER_ID); people.initPushHandling(GOOGLE_PROJECT_NUMBER); people.showNotificationIfAvailable(this);             BrainBox Network. Copyright@2015. All rights reserved  
  • 15.   ➔ Setup User Profile in Mixpanel JSONObject messageProps = new JSONObject(); try { messageProps.put("User Age","25"); } catch (JSONException e) { e.printStackTrace(); } mixpanel.registerSuperPropertiesOnce(messageProps); OR mixpanel.registerSuperProperties(messageProps);                       BrainBox Network. Copyright@2015. All rights reserved  
  • 16.   ➔ Set Super Properties try { final JSONObject userProfile = new JSONObject(); userProfile.put("$name" ,"TEST"); userProfile.put("$email" , "ABC@GMAIL.COM"); String timeStamp = new SimpleDateFormat("yyyy‐MM‐dd HH:mm:ss").format(new Date()); userProfile.put("$created", timeStamp); mixpanel.getPeople().set(userProfile); } catch (JSONException e) { e.printStackTrace(); }                 BrainBox Network. Copyright@2015. All rights reserved  
  • 17.   ➔ Tracking User Action mixpanel.track(“EVENT_NAME"); WRITE BELOW CODE IN ACTIVITY @Override protected void onDestroy() { super.onDestroy(); mixpanel.flush(); }                   BrainBox Network. Copyright@2015. All rights reserved  
  • 18.   CUSTOM NOTIFICATION    ➔ CREATE OWN RECEIVER (For Ex. My Receiver) : ➔ Insert Below code in app/src/main/AndroidManifest.xml <receiver android:name=“.My Receiver" android:permission="com.google.android.c2dm.permission.SEND"> <intent‐filter> <action android:name="com.google.android.c2dm.intent.RECEIVE"/> <category android:name="com.google.android.gcm.demo.app"/> </intent‐filter> <intent‐filter> <action android:name=“<GIVEN NAME (MYBROADCAST)>"> </action> </intent‐filter> </receiver>                           BrainBox Network. Copyright@2015. All rights reserved  
  • 19.     ➔ MYRECEIVER.JAVA class CODE public class MyReceiver extends BroadcastReceiver { Context context; @Override public void onReceive(Context context, Intent intent) { Bundle data = intent.getExtras(); String notificationMessage = data.getString("mp_message"); this.context=context; if(data.containsKey("IMAGE_KEY")) { //NOTIFICATION WITH IMAGE String image_url = data.getString("IMAGE_URL"); new DownloadImage().execute(image_url,notificationMessage); } else { //NOTIFICATION WITHOUT IMAGE simpleNotification(notificationMessage); } } public class DownloadImage extends AsyncTask<String,Void,Bitmap> { Bitmap message_bitmap = null; @Override protected Bitmap doInBackground(String... parms) { try { URL url = new URL(parms[0]); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoInput(true); connection.connect(); InputStream input = connection.getInputStream(); message_bitmap = BitmapFactory.decodeStream(input); int icon = R.mipmap.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); String title = "<APP_TITLE>"; Intent notificationIntent = null; notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.addCategory(Intent.CATEGORY_BROWSABLE); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | BrainBox Network. Copyright@2015. All rights reserved  
  • 20.   Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent1 = PendingIntent.getActivity(context, 0, notificationIntent, 0); Notification notification = new NotificationCompat.Builder(context) .setContentTitle(title) .setContentText(parms[1]) .setContentIntent(intent1) .setSmallIcon(icon) .setWhen(when) .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(message_bitmap)) .build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); } catch (Exception e) { e.printStackTrace(); } return message_bitmap; } @Override protected void onPostExecute(Bitmap aVoid) { super.onPostExecute(aVoid); } } public void simpleNotification(String message) { int icon = R.mipmap.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); String title = "<APP_TITLE>"; Intent notificationIntent = null; notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.addCategory(Intent.CATEGORY_BROWSABLE); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent1 =PendingIntent.getActivity(context, 0, notificationIntent, 0); Notification notification = new NotificationCompat.Builder(context) .setContentTitle(title) .setContentText(message) .setContentIntent(intent1) .setSmallIcon(icon) .setWhen(when) .build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); } BrainBox Network. Copyright@2015. All rights reserved  
  • 21.   } SEND IMAGE WITH PUSH NOTIFICATION FROM MIXPANEL  DASHBOARD    ➔ Create Push Notification in Mixpanel ➔ Set Audience ➔ Set your Push Notification ➔ Set Custom data (Extra data) ➔ For Image send Image_key For Eg: Image_key ‐> “12345”) and Image_url ‐> “​http://tineye.com/images/widgets/mona.jpg​” ➔ In Custom data ‐> In Json form‐>Send                     BrainBox Network. Copyright@2015. All rights reserved  
  • 23.   Thank You So Very Much For queries please write on ​ashish@mobifly.in Developed By Mohit Saini Android Developer ‐ Mobifly mobifly.in     BrainBox Network. Copyright@2015. All rights reserved