GithubHelp home page GithubHelp logo

android-sdk's Introduction

Marketo Mobile SDK for Android 0.8.12

The Marketo Mobile SDK allows integration with Marketo Mobile Engagement (MME).

Change Log

v0.8.12 (April 25, 2024)

  • Enhancements & Bug fixes.

v0.8.11 (Jan 29, 2024)

  • Enhancements & Bug fixes.

v0.8.10 (August 29, 2023)

  • Enhancements & Bug fixes.

v0.8.9 (June 05, 2023)

  • Added parameter to capture the type of framework used for development (native, ionic, phonegap or reactnative)

v0.8.8 (May 25, 2022)

  • Added support for Android API Level 31
  • Mnimum support Android API Level is now 21

v0.8.4 (Mar 23, 2021)

  • Bug fixes

v0.8.2 (Feb 25, 2020)

  • Added Android https TLSv1.3 compliance

v0.8.1 (Jul 18, 2019)

  • Fixed Bugs

v0.8.0 (Mar 26, 2019)

  • Fixed Bugs

v0.7.9 (Mar 04, 2019)

  • FCM changes to support custom Marketo Push Notification Receiver
  • Configured Push Notification Channel Name.
  • Fixed Bugs

v0.7.8 (Dec 10, 2018)

  • Added Support for Firebase Cloud Messaging
  • Fixed Bugs

v0.7.7 (May 25, 2018)

  • Added Support for Android API Level P (28)
  • Fixed Bugs

v0.7.6 (January 18, 2018)

  • Using Android Activity Lifecycle Callbacks
  • Deprecated Marketo.onStart() and Marketo.onStop(), no longer required
  • Added support for Android API Levels 26 and 27
  • The minimum supported Android API Level is now 14

v0.7.5 (August 15, 2017)

  • Fixed bug that crashed app when passing deeplink such as ":" to MarketoActivity

v0.7.3 - v0.7.4 (June 7, 2017)

  • Exposed removeDevicePushToken() method
  • Notifications are now dismissed from the notification center after tap (Android 4.0)
  • Custom large notification icon no longer shows default image (Android 4.0)

v0.7.2 (November 30, 2016)

  • Fixed bug when using Priority method in Android versions previous to 5.0
  • Default sound in Android is now on when user receives a notification
  • Android Push Notification text now wrap to make it more readable
  • Migrated from HttpClient to HttpURLConnection

v0.7.1 (November 4, 2016)

  • Remove GET_ACCOUNTS permission check
  • No longer stacking push notifications
  • Catching client protocol exception

v0.7.0 (October 13, 2016)

  • Supporting Android Version 7.0

v0.6.4 (August 22, 2016)

  • Exposed method [MarketoSDK reportAll] to immediately send events

v0.6.3 (July 15, 2016)

  • Bug fixes related to inapp
  • added display frequency 'once'

v0.6.0 (June 10, 2016)

  • InApp Notifications

v0.5.3

  • Fixed bug that stop push notification when app was closed

v0.5.2

  • Removed deprecated android methods to allow building with Proguard

v0.5.1

  • Fixed intent.getAction condition

v0.5.0

  • New secure access feature
  • New app type selection
  • Android notificaiton config large icon

Issues

If you encounter issues using or integrating this plugin, please file a support ticket at support.marketo.com

Marketo Android SDK Installation Guide

Prerequisites

  1. Register an application in Marketo Admin portal, get your application secret key and munchkin id.
  2. Configure Android Push access learn here

Android SDK Setup

Include the following URL in your Application gradle file:

implementation ‘com.marketo:MarketoSDK:0.8.2’

(Note) Marekto SDK supports Android API Level 14 and above

(Troubleshooting)

If following error occures while building application with marketo sdk v0.7.8 .
Caused by: org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.MetaDataParseException: inconsistent module metadata found. Descriptor: com.marketo:MarketoSDK:0.7.7 Errors: bad version: expected='0.7.8' found='0.7.7'

Follow steps:

  1. You can delete all the existing artifacts (artifacts and metadata) Gradle has downloaded using:

For Unix:

rm -rf $HOME/.gradle/caches/

For Windows:

rmdir C:\Users\[username]\.gradle\caches\
  1. Run gradle build (or gradlew build if using gradle wrapper) in the project's root directory.

Configure Permissions

  • Add following permission inside application tag.

Open AndroidManifest.xml and add following permissions. Your app must request the “INTERNET” and “ACCESS_NETWORK_STATE” permissions. If your app already requests these permissions, then skip this step.

    <usespermission android:name="android.permission.INTERNET"/>
    <usespermission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Note :- If the Build vesion is Android P then please Add following Permission

  <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

Android Test Devices

Add Marketo Activity in manifest file inside application tag.

    <activity android:name="com.marketo.MarketoActivity"  android:configChanges="orientation|screenSize" >
        <intent-filter android:label="MarketoActivity" >
            <action  android:name="android.intent.action.VIEW"/>
            <category  android:name="android.intent.category.DEFAULT"/>
            <category  android:name="android.intent.category.BROWSABLE"/>
            <data android:host="add_test_device" android:scheme="mkto" />
        </intent-filter>
    </activity>

SDK Initialization

  • Open your Application or Activity class in your app and import the Marketo SDK into your Activity before setContentView or in Application Context.
   // Initialize Marketo
   Marketo marketoSdk = Marketo.getInstance(getApplicationContext());
   marketoSdk.initializeSDK("munchkinAccountId","secretKey");

Marketo FCM Push Notification Integration.

  1. Configure Firebase App on Firebase Console.

    • Create/Add a Project on Firebase Console.
      • In the Firebase console, select Add Project.
      • Select your GCM project from the list of existing Google Cloud projects, and select Add Firebase.
      • In the Firebase welcome screen, select Add Firebase to your Android App.
      • Provide your package name and SHA-1, and select Add App. A new google-services.json file for your Firebase app is downloaded.
      • Select Continue and follow the detailed instructions for adding the Google Services plugin in Android Studio.
    • Navigate to ‘Project Settings’ in Project Overview
      • Click on ‘General’ tab. Download the ‘google-services.json’ file.
      • Click on ‘Cloud Messaging’ tab. Copy ‘Server Key’ & ‘Sender ID’. Provide these ‘Server Key’ & ‘Sender ID’ to Marketo.
    • Configure FCM changes in Android App
      • Switch to the Project view in Android Studio to see your project root directory
      • Move the downloaded ‘google-services.json’ file into your Android app module root directory
      • In Project-level build.gradle add the following:
        buildscript {
         dependencies {
           Classpath 'com.google.gms:google-services:4.0.1'
         }
        }
      • In App-level build.gradle add the following:
        dependencies {
         compile 'com.google.firebase:firebase-core:17.3.4'
        }
        // Add to the bottom of the file
        apply plugin: 'com.google.gms.google-services'
      • Finally, click on “Sync now” in the bar that appears in the ID
  2. Add / Edit FCM Messaging Service

    • If Customer don’t have their own FireBaseMessagingService they need to add MyFirebaseMessagingService.java.

      import com.google.firebase.messaging.FirebaseMessagingService;
      import com.google.firebase.messaging.RemoteMessage;
      import com.marketo.Marketo;
      
      public class MyFirebaseMessagingService extends FirebaseMessagingService {
          public static final String TAG = "MsgFirebaseServ";
      
          @Override
          public void onNewToken(String token) {
              super.onNewToken(token);
              Marketo marketoSdk = Marketo.getInstance(getApplicationContext());
              marketoSdk.setPushNotificaitonToken(token);
          }
      
          @Override
          public void onMessageReceived(RemoteMessage remoteMessage) {
              Marketo marketoSdk = Marketo.getInstance(getApplicationContext());
              marketoSdk.showPushNotificaiton(remoteMessage);
          }
      }
    • If Customer have their own FirebaseMessagingService then they must provide Push notification token once received. They also need to provide RemoteMessage Object once Received.

          @Override
          public void onNewToken(String s) {
              super.onNewToken(s);
              Marketo marketoSdk = Marketo.getInstance(getApplicationContext());
              marketoSdk.setPushNotificaitonToken(s);
              // Add your custom logic here...
      
          }
          @Override
          public void onMessageReceived(RemoteMessage remoteMessage) {
              //check for the data/notification entry from the payload
              Marketo marketoSdk = Marketo.getInstance(getApplicationContext());
              marketoSdk.showPushNotificaiton(remoteMessage);
              // Add your custom logic here...
      
       }
  3. Edit your app’s manifest

    • The FCM SDK automatically adds all required permissions as well as the required receiver functionality. Make sure to remove the following obsolete (and potentially harmful, as they may cause message duplication) elements from your app’s manifest.

      <permission android:name="<your-package-name>.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
      <uses-permission android:name="<your-package-name>.permission.C2D_MESSAGE" />
      
      <receiver>
          android:name="com.google.android.gms.gcm.GcmReceiver"
          android:exported="true"
          android:permission="com.google.android.c2dm.permission.SEND">
          <intent-filter>
              <action android:name="com.google.android.c2dm.intent.RECEIVE" />
              <category android:name="<your-package-name>" />
          </intent-filter>
      </receiver>
      
      <meta-data
          android:name="com.google.android.gms.version"
          android:value="@integer/google_play_services_version" />
    • Add Following in the AndroidManifest.xml

      <service android:name=".MyFirebaseMessagingService">
         <intent-filter>
              <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
              <action android:name="com.google.firebase.MESSAGING_EVENT"/>
         </intent-filter>
      </service>
  4. Initialize Marketo Push

    • After saving the configuration above, you must initialize Marketo Push Notification. Create or open your Application class and copy/paste the code below. You can get your sender ID from the Firebase Console. You need to provide any push notification CHANNEL_NAME which will be shown under App's Notification Settings. (By default CHANNEL_NAME will be 'MKTO')

      marketoSdk.initializeMarketoPush(SENDER_ID, CHANNEL_NAME);
The token can also be unregistered when user logs out.
marketoSdk.uninitailizeMarketoPush();

###Set Notification Icon (Optional)

To configure a custom notification icon the following method should be called.

    MarketoConfig.Notification config = new MarketoConfig.Notification();
    // Optional bitmap for honeycomb and above
    config.setNotificationLargeIcon(bitmap);
    // Required icon Resource ID
    config.setNotificationSmallIcon(R.id.notification_small_icon);
    // Set the configuration
    Marketo.getInstance(context).setNotificationConfig(config);
    // Get the configuration set
    Marketo.getInstance(context).getNotificationConfig(config);

###How to Create User Profile on Android

  • Create User Profile

You can create rich profiles by sending user fields as shown below.

    MarketoLead profile = new MarketoLead();
    // Get user profile from network and populate
    try {
        profile.setEmail("[email protected]");
        profile.setFirstName("Mike");
        profile.setLastName("Gray");
        profile.setFacebookId("facebookid");
        profile.setAddress("1234 King Fish Blvd");
    }
    catch (MktoException e) {
        e.printStackTrace();
    }
  • Add more Standard Fields.
    // Add other custom fields
    profile.setCustomField("mobilePhone", "123.456.7890");
    profile.setCustomField("numberOfEmployees", "10");
    profile.setCustomField("phone", "123.456.7890");
    profile.setCustomField("rating", "R");
    profile.setCustomField("facebookDisplayName", "mini");
    profile.setCustomField("facebookReach", "10");
    profile.setCustomField("facebookReferredEnrollments", "100");
    profile.setCustomField("facebookReferredVisits", "9998");
    profile.setCustomField("lastReferredEnrollment", "03/01/2015");
    profile.setCustomField("lastReferredVisit", "03/01/2015");
    profile.setCustomField("linkedInDisplayName", "Android");
  • Report User Profile
    MarketoLead profile = new MarketoLead();
    // This method will update user profile
    marketoSdk.associateLead(profile);

###You can track user interaction by sending custom actions.

  • Send custom action.
    Marketo.reportAction("Login", null);
  • Add custom action meta data.
    MarketoActionMetaData meta = new MarketoActionMetaData();
    meta.setActionType("Shopping");
    meta.setActionDetails("RedShirt");
    meta.setActionLength("20");
    meta.setActionMetric("30");

    Marketo.reportAction("Bought Shirt", meta);

ProGuard Configuration (Optional)

If you are using ProGuard for your app, then add the following lines in your proguard.cfg file. The file will be located within your project folder. Adding this code will exclude the Marketo SDK from the obfuscation process.

    -dontwarn com.marketo.*
    -dontnote com.marketo.*
    -keep class com.marketo.**{ *; }

###Advanced Security Access Mode

This setup must be implemented before the Secure Access mode has been enable via the Marketo Admin -> Mobile Apps & Devices page. The following further steps describe the process required to complete the security validation process:

Secure Access mode requires implementing the signature algorithm on the customer server-side that will provide an endpoint to retrieve the access key, calculated signature, expiry timestamp, and email. This algorithm requires the user access key, access secret, email, timestamp, and device id to preform the calculation. The customer is responsible for setting up endpoint, implementing the algorithm to preform signature calculations, and also keep expiration timestamp fresh.Link Here

The Marketo SDK exposes new methods to set and remove the security signature. There is also a utility method to retrieve the device ID. The device ID should be passed along with the email, upon login, to the customer server for use in calculating the security signature. The SDK should the hit new endpoint, pointing to algorithm listed above, to retrieve the necessary fields to instantiate the signature object. Setting this signature in the SDK is a necessary step if the Security Access Mode has been enabled in Marketo Mobile Admin.

      Marketo sdk = Marketo.getInstance(getApplicationContext());
      // set signature
      MarketoConfig.SecureMode secureMode = new MarketoConfig.SecureMode();
      secureMode.setAccessKey(<ACCESS_KEY>);
      secureMode.setEmail(<EMAIL_ADDRESS>);
      secureMode.setSignature(<SIGNATURE_TOKEN>);
      secureMode.setTimestamp(<EXPIRY_DATE>);
      if (secureMode.isValid()) {
        sdk.setSecureSignature(secureMode);
      }
      // remove signature
      sdk.removeSecureSignature();
      // get device id
      sdk.getDeviceId();

android-sdk's People

Contributors

bsadiwala avatar everlyd avatar glo40610 avatar kodeshpa avatar marketoreleng avatar mbijapur avatar pandemanish avatar skharemarketo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-sdk's Issues

Proguard issue

Hi, I'm using proguard with Marketo version 0.7.7 and after adding this library to my project I can't make a build 'cause I have some troubles with proguard. I've added these lines to rules:
-dontwarn com.marketo.*
-dontnote com.marketo.*
-keep class com.marketo.**{ *; }

But it's not enough as I see. Also, I don't know what is an error here and how fix it, could you review it?
The first one is output without Marketo. The second one - when marketo is in the project.

  1. https://prnt.sc/li86ix
  2. http://prntscr.com/li886h

Crashing App after receiving push on Android 8.0

Here is the stack trace:

Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.marketo.MarketoBroadcastReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.fivestars.mma cmp=com.fivestars.mma/com.marketo.MarketoIntentService (has extras) }: app is in background uid UidRecord{c72cc0e u0a179 RCVR idle change:idle|uncached procs:1 seq(0,0,0)}
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:3194)
       at android.app.ActivityThread.-wrap17(Unknown Source)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1672)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.fivestars.mma cmp=com.fivestars.mma/com.marketo.MarketoIntentService (has extras) }: app is in background uid UidRecord{c72cc0e u0a179 RCVR idle change:idle|uncached procs:1 seq(0,0,0)}
       at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1521)
       at android.app.ContextImpl.startService(ContextImpl.java:1477)
       at android.content.ContextWrapper.startService(ContextWrapper.java:650)
       at android.content.ContextWrapper.startService(ContextWrapper.java:650)
       at marketo.push.MktoWakefulBroadcastReceiver.a(SourceFile:86)
       at com.marketo.MarketoBroadcastReceiver.onReceive(SourceFile:42)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:3187)
       at android.app.ActivityThread.-wrap17(Unknown Source)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1672)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Fix might me moving from IntentService to JobIntentService.

ANR caused by Marketo SDK 0.8.0

I'm using the latest Marketo SDK 0.8.0 and I'm getting reports of ANRs in production. Please investigate and fix as soon as you can. Please and thank you!

Stacktrace:

ANR: Application did not respond for at least 5000 ms
        at com.marketo.Marketo.b(SourceFile:20822)
        at com.marketo.Marketo$a.onActivityStopped(SourceFile:947)
        at android.app.Application.dispatchActivityStopped(Application.java:282)
        at android.app.Activity.onStop(Activity.java:1984)
        at androidx.fragment.app.FragmentActivity.onStop(FragmentActivity.java:541)
        at androidx.appcompat.app.AppCompatActivity.onStop(AppCompatActivity.java:185)

Threads:

SourceFile:20822com.marketo.Marketo.b	
SourceFile:947com.marketo.Marketo$a.onActivityStopped	
Application.java:282android.app.Application.dispatchActivityStopped	
Activity.java:1984android.app.Activity.onStop	
FragmentActivity.java:541androidx.fragment.app.FragmentActivity.onStop	
AppCompatActivity.java:185androidx.appcompat.app.AppCompatActivity.onStop	
Base.java:95com.mobilemarket.app.Base.onStop	
MyActivity.kt:214com.mobilemarket.onboarding.MyActivity.onStop	
Instrumentation.java:1432android.app.Instrumentation.callActivityOnStop	
Activity.java:7653android.app.Activity.performStop	
ActivityThread.java:4372android.app.ActivityThread.callActivityOnStop	
ActivityThread.java:4350android.app.ActivityThread.performStopActivityInner	
ActivityThread.java:4425android.app.ActivityThread.handleStopActivity	
TransactionExecutor.java:192android.app.servertransaction.TransactionExecutor.performLifecycleSequence	
TransactionExecutor.java:165android.app.servertransaction.TransactionExecutor.cycleToPath	
TransactionExecutor.java:142android.app.servertransaction.TransactionExecutor.executeLifecycleState	
TransactionExecutor.java:70android.app.servertransaction.TransactionExecutor.execute	
ActivityThread.java:1947android.app.ActivityThread$H.handleMessage	
Handler.java:106android.os.Handler.dispatchMessage	
Looper.java:214android.os.Looper.loop	
ActivityThread.java:7032android.app.ActivityThread.main	
Method.java:-2java.lang.reflect.Method.invoke	
RuntimeInit.java:494com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run	
ZygoteInit.java:965com.android.internal.os.ZygoteInit.main

Support Firebase Cloud Messaging

Google has replaced GCM with FCM (Firebase Cloud Messaging). This library should add support for FCM or add a variant that does.

Use ActivityLifecycleCallbacks instead of imposing onStart/onStop ceremony on all Activities

It doesn't seem that there is any real need to impose the requirement that all consumers of this SDK perform the following ceremony on every Activity in their Application:

  1. Configure activities. Add Marketo.onStart, Marketo.onStop in all or in base activity as shown below.

This burden can removed from SDK consumers if the Marketo SDK uses Application.ActivityLifecycleCallbacks to do whatever work is necessary in onStart and onStop.

Add Marketo SDK to JCenter and/or MavenCentral

Downloading and adding an AAR to the project works fine. However it would be much more convenient and quick to get set up if it was added to JCenter and/or MavenCentral so that we could just add one line to a Gradle build file to add the Marketo library.

Could we please have builds deployed to JCenter and/or MavenCentral?

The app still receive notification when the function uninitializeMarketoPush is called

Hello everyone,
I'm using Marketo SDK to push notifications for my React Native project. I have an issue when the user logout, uninitializeMarketoPush of SDK is called, and I saw logs from Makero SDK: 'Unregistered device from FCM'. But when I push a notification from Marketo admin
, the app still receives a notification.
You can see my screenshot below.

OS: Android
Version: 11

Screenshot 2023-10-24 at 15 46 06 Screenshot 2023-10-24 at 15 46 55

SDK is incompatible with Android SDK 23

I have added the Marketo android SDK to our app. When minifying the app through ProGuard, I notice that the app is now failing to build as it using a deprecated android method:

Warning:marketo.push.a: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification

Marketo android SDK Failed to init

Hi all, first time connecting to android Marketo 0.8.6

I am getting an IOException, 'failed to initialize MarketoSDK 0.8.6 IOException'

Munchkin ID: 824-XEX-790.

I have read on iOS Side that initialization fails because the Marketo subscription is not set up correctly?

Thank you

Do not track user's location with LocationManager

The LOCATION is classified as a dangerous permission group by Android and therefore requires a permission prompt for targetSdkVersion 23 and higher. Regardless, collecting information about the user's location is a highly offensive practice for applications that do not incorporate location into their functionality. There is no need for Marketo to attempt to collect location information by default.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.