Setup Swift Bridging Header
-
Go to File > New > File and Select “Header File”.
-
Name the file “<ProjectName>-Bridging-Header”.
-
Go to Project > Target > Build Phases > Swift Compiler > Code Generation. Add the following path to Objective-Bridging Header:
$(PODS_ROOT)/<_ProjectName_>-Bridging-Header.h
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 “Mobile Apps and Devices”.
-
Open your AppDelegate.m file (Objective-C) or Bridging file (Swift) and import the Marketo.h header file.
#import <MarketoFramework/MarketoFramework.h>
-
Paste the following code inside the
application:didFinishLaunchingWithOptions
: function.Note that we must pass “native” as framework type for Native Apps.
Marketo *sharedInstance = [Marketo sharedInstance];
[sharedInstance initializeWithMunchkinID:@"munchkinAccountId" appSecret:@"secretKey" mobileFrameworkType:@"native" launchOptions:launchOptions];
let sharedInstance: Marketo = Marketo.sharedInstance()
sharedInstance.initialize(withMunchkinID: "munchkinAccountId", appSecret: "secretKey", mobileFrameworkType: "native", launchOptions: launchOptions)
- Replace
munkinAccountId
andsecretKey
above using your “Munchkin Account ID” and “Secret Key” which are found in the Marketo Admin > Mobile Apps and Devices section.
iOS Test Devices
- Select Project > Target > Info > URL Types.
- Add identifier: $
- Set URL Schemes:
mkto-<Secret Key_>
- Include application
sourceApplication
to AppDelegate.m file (Objective-C)
Handle Custom Url Type in AppDelegate
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
return [[Marketo sharedInstance] application:app
openURL:url
options:options];
}
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
- Add an application in Marketo Admin (obtain your application Secret Key and Munchkin Id)
- Setup Push Notifications (optional)
- Download Marketo SDK for Android
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'
-
The root
build.gradle
file should havebuildscript { repositories { google() mavenCentral() }
-
Sync your Project with Gradle Files
Configure Permissions
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.
<uses‐permission android:name="android.permission.INTERNET"></uses‐permission>
<uses‐permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses‐permission>
Initialize SDK
-
Open the 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("native","munchkinAccountId","secretKey");
-
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.-dontwarn com.marketo.* -dontnote com.marketo.* -keep class com.marketo.`{ *; }
Android Test Devices
Add “MarketoActivity” 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’s Firebase Cloud Messaging (FCM) with this SDK.
Adding FCM to your Application
-
Integrate latest Marketo Android SDK in Android App. Steps are available at GitHub.
-
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 newgoogle-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.
- In the Firebase console, select
-
Navigate to ‘Project Settings’ in Project Overview
- Click ‘General’ tab. Download the ‘google-services.json’ file.
- Click on ‘Cloud Messaging’ tab. Copy ‘Server Key’ and ‘Sender ID’. Provide these ‘Server Key’ and ‘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.0' } }
-
In App-level build.gradle, add the following:
dependencies { compile 'com.google.firebase:firebase-core:17.4.0' } // Add to the bottom of the file apply plugin: 'com.google.gms.google-services'
-
Finally, click “Sync now” in the bar that appears in the ID
-
-
-
Edit your app’s 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’s manifest:
<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>
-