51黑料不打烊

Installation

Installation instructions for Marketo Mobile SDK. The steps below are required to send Push Notifications and/or In-App Messages.

Install Marketo SDK on iOS

Prerequisites

  1. Add an application in Marketo Admin聽(obtain your聽application Secret Key and Munchkin Id)
  2. Setup Push Notifications听(辞辫迟颈辞苍补濒)

Install Framework via CocoaPods

  1. Install CocoaPods. $ sudo gem install cocoapods
  2. Change directory to your project directory and create a Podfile with smart defaults. $ pod init
  3. Open your Podfile. $ open -a Xcode Podfile
  4. Add the following line to your Podfile. $ pod 'Marketo-iOS-SDK'
  5. Save and close your Podfile.
  6. Download and install Marketo iOS SDK. $ pod install
  7. Open workspace in Xcode. $ open App.xcworkspace

Install Framework using Swift Package Manager

  1. Select your project from the Project Navigator and under 鈥淎dd Package Dependency鈥, click 鈥+鈥 as shown below :

    Add Dependency

  2. Add Marketo package from this Repo. Add this URL for this repository: .

    Repo URL

  3. Now add the Resource bundle as shown: Locate MarketoFramework.XCframework in project navigator and open it in Finder. Drag and drop MKTResources.bundle to Copy Bundle Resources.

Setup Swift Bridging Header

  1. Go to File > New > File and Select 鈥淗eader File鈥.

    Select "Header File"

  2. Name the file 鈥<ProjectName>-叠谤颈诲驳颈苍驳-贬别补诲别谤鈥.

  3. Go to Project > Target > Build Phases > Swift Compiler > Code Generation. Add the following path to Objective-Bridging Header:

    $(PODS_ROOT)/<_ProjectName_>-Bridging-Header.h

    Build Phases

Initialize SDK

Before you can use the Marketo iOS SDK, you must initialize it with your Munchkin Account Id and App Secret Key. You can find each of these in the Marketo Admin area underneath 鈥淢obile Apps and Devices鈥.

  1. Open your AppDelegate.m file (Objective-C) or Bridging file (Swift) and import the Marketo.h header file.

    code language-none
    #import <MarketoFramework/MarketoFramework.h>
    
  2. Paste the following code inside the application:didFinishLaunchingWithOptions: function.

    Note that we must pass 鈥渘ative鈥 as framework type for Native Apps.

Objective C
code language-none
Marketo *sharedInstance = [Marketo sharedInstance];

[sharedInstance initializeWithMunchkinID:@"munchkinAccountId" appSecret:@"secretKey" mobileFrameworkType:@"native" launchOptions:launchOptions];
Swift
code language-none
let sharedInstance: Marketo = Marketo.sharedInstance()

sharedInstance.initialize(withMunchkinID: "munchkinAccountId", appSecret: "secretKey", mobileFrameworkType: "native", launchOptions: launchOptions)
  1. Replace munkinAccountId and secretKey above using your 鈥淢unchkin Account ID鈥 and 鈥淪ecret Key鈥 which are found in the Marketo Admin > Mobile Apps and Devices section.

iOS Test Devices

  1. Select Project > Target > Info > URL Types.
  2. Add identifier: $
  3. Set URL Schemes: mkto-<Secret Key_>
  4. Include applicationsourceApplication to AppDelegate.m file (Objective-C)

Handle Custom Url Type in AppDelegate

Objective C
code language-none
- (BOOL)application:(UIApplication *)app
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{

    return [[Marketo sharedInstance] application:app
                                         openURL:url
                                         options:options];
}
Swift
code language-none
private func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
    {
        return Marketo.sharedInstance().application(app, open: url, options: options)
    }

How to Install Marketo SDK on Android

Prerequisites

  1. Add an application in Marketo Admin聽(obtain your聽application Secret Key and Munchkin Id)
  2. Setup Push Notifications听(辞辫迟颈辞苍补濒)

Android SDK Setup with Gradle

1.聽In the application level build.gradle file, under the dependencies section add

implementation 'com.marketo:MarketoSDK:0.8.9'

  1. The root build.gradle file should have

    code language-none
    buildscript {
        repositories {
            google()
            mavenCentral()
        }
    
  2. Sync聽your Project with Gradle Files

Configure Permissions

Open AndroidManifest.xml and add following permissions. Your app must request the 鈥淚NTERNET鈥 and 鈥淎CCESS_NETWORK_STATE鈥 permissions. If your app already requests these permissions, then skip this step.

<uses鈥恜ermission android:name="android.permission.INTERNET">&#虫3颁;/耻蝉别蝉鈥恜别谤尘颈蝉蝉颈辞苍>
<uses鈥恜ermission android:name="android.permission.ACCESS_NETWORK_STATE">&#虫3颁;/耻蝉别蝉鈥恜别谤尘颈蝉蝉颈辞苍>

Initialize SDK

  1. Open the Application or Activity class in your app and import the Marketo SDK into your Activity before setContentView or in Application Context.

    code language-java
    // Initialize Marketo
    Marketo marketoSdk = Marketo.getInstance(getApplicationContext());
    marketoSdk.initializeSDK("native","munchkinAccountId","secretKey");
    
  2. ProGuard Configuration (Optional)

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

    code language-none
    -dontwarn com.marketo.*
    -dontnote com.marketo.*
    -keep class com.marketo.`{ *; }
    

Android Test Devices

Add 鈥淢arketoActivity鈥 to AndroidManifest.xml 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>

Firebase Cloud Messaging Support

The MME Software Development Kit (SDK) for Android has been updated to a more modern, stable, and scalable framework that contains more flexibility and new engineering features for your Android app developer.

Android app developers can now directly use Google鈥檚 (FCM) with this SDK.

Adding FCM to your Application

  1. Integrate latest Marketo Android SDK in Android App.聽 Steps are available at .

  2. Configure Firebase App on Firebase Console.

    1. Create/Add a Project on聽Firebase Console.

      1. In the聽, select聽Add Project.
      2. Select your GCM project from the list of existing Google Cloud projects, and select聽Add Firebase.
      3. In the Firebase welcome screen, select聽Add Firebase to your Android App.
      4. Provide your package name and SHA-1, and select聽Add App. A new聽google-services.json聽file for your Firebase app is downloaded.
      5. 厂别濒别肠迟听Continue聽and follow the detailed instructions for adding the Google Services plugin in Android Studio.
    2. Navigate to 鈥楶roject Settings鈥 in Project Overview

      1. Click 鈥楪eneral鈥 tab. Download the 鈥榞oogle-services.json鈥 file.
      2. Click聽on 鈥楥loud Messaging鈥 tab. Copy 鈥楽erver Key鈥 and 鈥楽ender ID鈥. Provide these 鈥楽erver Key鈥 and 鈥楽ender ID鈥 to Marketo.
    3. Configure FCM changes in Android App

      1. Switch to the聽Project聽view in Android Studio to see your project root directory

        1. Move the downloaded 鈥榞oogle-services.json鈥 file into your Android app module root directory

        2. In聽Project-level build.gradle, add the following:

          code language-none
          buildscript {
            dependencies {
              classpath 'com.google.gms:google-services:4.0.0'
            }
          }
          
        3. In App-level build.gradle, add the following:

          code language-none
          dependencies {
            compile 'com.google.firebase:firebase-core:17.4.0'
          }
          // Add to the bottom of the file
          apply plugin: 'com.google.gms.google-services'
          
        4. Finally, click 鈥淪ync now鈥 in the bar that appears in the ID

    4. Edit your app鈥檚 manifest The FCM SDK automatically adds all required permissions and the required receiver functionality. Make sure to remove the following obsolete (and potentially harmful, as they may cause message duplication) elements from your app鈥檚 manifest:

      code language-xml
      <uses-permission android:name="android.permission.WAKE_LOCK" />
      <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>
      
recommendation-more-help
bb269a6d-047a-4bf7-9acd-23ad9a63dc59