The Marketo Mobile SDK allows integration with Marketo Mobile Engagement (MME).
Installation instructions and more are here.
Change Log
v0.8.6 (March 22, 2024)
- Enhancements & bug fixes.
v0.8.5 (January 16, 2024)
- SDK includes iOS Privacy manifest as per Apple guidelines.
v0.8.4 (August 10, 2023)
- Enhancements & bug fixes.
v0.8.3 (July 24, 2023)
- Swift package manager support for iOS-SDK is added.
- Bug fixes & enhancements.
v0.8.2 (June 26, 2023)
- Added support for XCFramework to support multiple platforms.
v0.8.1 (June 05, 2023)
- Initialization param to include development framework type (viz., native, cordova, ionic or reactnative)
- Bug fixes & enhancements
v0.8.0 (March 06, 2023)
- Upgraded SDK minimum iOS version support to 12.0 & enhancements
v0.7.8 (August 19, 2021)
- Bug fixes & enhancements
v0.7.7 (March 6, 2020)
- Fixed unregister device token bug
v0.7.6 (September 4, 2018)
- Fixed tap gesture error at In-app
v0.7.5 (September 8, 2017)
- Fixed build errors and warnings in xCode 9
v0.7.4 (July 7, 2017)
- Exposed removeDevicePushToken() method
v0.7.1 (November 24, 2016)
- Handling notification in loadingOptions for iOS 10 to track tap activity when app is closed.
v0.7.0 (October 5, 2016)
- Using UNNotification to handle push received while app is in foreground with a local notification
v0.6.4 (August 23, 2016)
- Exposed method [MarketoSDK reportAll] to immediately send events
v0.6.3 (July 15, 2016)
- Support for InApp display frequency once.
v0.6.0 (June, 11 2016)
- InApp Notifications
v0.5.1 - v0.5.3
- Fixed new_install bug
- Fix for version bug
v0.5.0
- Advanced secure access
- Bitcode refactor
If you encounter issues using or integrating this plugin, please file a support ticket at support.marketo.com
1. Register an application in Marketo Admin portal, get your application secret key and munchkin id.
3. Configure iOS Push access learn here.
sudo gem install cocoapods
pod init
open -a Xcode Podfile
pod 'Marketo-iOS-SDK'
pod install
open App.xcworkspace
1. Select project from the Project Navigator & under Add Package Dependency, click ‘+’ as shown below :
2. Add Marketo package from this Repo. Add this URL for this repository: https://github.com/Marketo/ios-sdk.git.
3. Now add Resource bundle as shown : Locate MarketoFramework.XCframework
in project nagivator & open it in finder. Then drag & drop MKTResources.bundle
to Copy Bundle Resources
#####1. Go to File > New > File and Select Header File:
3. Go to Project->Target->Build Phases->Swift Compiler - Code Generation-> Add the following path to Objective-Bridging
#####Header: $(PODS_ROOT)/-Bridging-Header.h
#SDK Initialization
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.
#import <MarketoFramework/MarketoFramework.h>
Marketo *sharedInstance = [Marketo sharedInstance];
[sharedInstance initializeWithMunchkinID:@"munchkinAccountId" appSecret:@"secretKey" mobileFrameworkType:@"native" launchOptions:launchOptions];
let sharedInstance: Marketo = Marketo.sharedInstance()
sharedInstance.initializeWithMunchkinID("munchkinAccountId", appSecret: "secretKey", mobileFrameworkType: "native", launchOptions: launchOptions)
3. Replace munkinAccountId and secretKey above using your Munchkin Account Id and Secret Key which are found in the Marketo Admin Mobile Apps section.
#Configure Push Notifications on Apple Developer Account
5. Enable �Apple Push Notification service SSL (Sandbox & Production)� checkbox, and click �Continue�.
#Enable Push Notifications in xCode
#Enable Push Notifications in App with Marketo SDK
#import <UserNotifications/UserNotifications.h>
import UserNotifications
@interface AppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate>
class AppDelegate: UIResponder, UIApplicationDelegate , UNUserNotificationCenterDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// ...
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if(!error){
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] registerForRemoteNotifications];
});
}
}];
// ...
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// ...
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
if let error = error {
print("\(error.localizedDescription)")
} else {
DispatchQueue.main.async {
application.registerForRemoteNotifications()
}
}
}
// ...
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Register the push token with Marketo
[[Marketo sharedInstance] registerPushDeviceToken:deviceToken];
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
// Register the push token with Marketo
Marketo.sharedInstance().registerPushDeviceToken(deviceToken)
}
[[Marketo sharedInstance] unregisterPushDeviceToken];
Marketo.sharedInstance().unregisterPushDeviceToken
5. Add the following method in AppDelegate : By using this method you can either present alert, sound or increase badge while the app is in foreground. You must call completionHandler of your choice in this Method.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
NSLog(@"Notification is triggered");
completionHandler(UNNotificationPresentationOptionAlert); // OR
// completionHandler(UNNotificationPresentationOptionBadge); OR
// completionHandler(UNNotificationPresentationOptionSound);
#endif
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert) // OR
// completionHandler(.badge) OR
//completionHandler(.sound)
}
6. Handle newly received Push notification in AppDelegate : The method will be called on the delegate when the user responded to the notification by opening the application, dismissing the notification or choosing a UNNotificationAction. The delegate must be set before the application returns from applicationDidFinishLaunching:.
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void(^)())completionHandler {
[[Marketo sharedInstance] userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
Marketo.sharedInstance().userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}
#iOS Test Devices
- (BOOL)application:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
return [[Marketo sharedInstance] application:app
openURL:url
options:nil];
}
private func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
{
return Marketo.sharedInstance().application(app, open: url, options: options)
}
#How to Create User Profiles on iOS
MarketoLead *profile = [[MarketoLead alloc] init];
// Get user profile from network and populate
[profile setEmail:@"[email protected]"];
[profile setFirstName:@"John"];
[profile setLastName:@"Doe"];
[profile setAddress:@"1234KingFishSt"];
[profile setCity:@"SouthPadreIsland"];
[profile setState:@"CA"];
[profile setPostalCode:@"78596"];
[profile setCountry:@"USA"];
[profile setGender:@"male"];
[profile setLeadSource:@"_facebook_ads"];
[profile setBirthDay:@"01/01/1985"];
[profile setFacebookId:@"facebookid"];
[profile setFacebookProfileURL:@"facebook.com/profile"];
[profile setFacebookProfilePicURL:@"faceboook.com/profile/pic"];
[profile setLinkedInId:@"linkedinid"];
[profile setTwitterId:@"twitterid"];
let profile = MarketoLead()
// Get user profile from network and populate
profile.setEmail("[email protected]")
profile.setFirstName("John")
profile.setLastName("Doe")
profile.setAddress("1234KingFishSt")
profile.setCity("SouthPadreIsland")
profile.setState("CA")
profile.setPostalCode("78596")
profile.setCountry("USA")
profile.setGender("male")
profile.setLeadSource("_facebook_ads")
profile.setBirthDay("01/01/1985")
profile.setFacebookId("facebookid")
profile.setFacebookProfileURL("facebook.com/profile")
profile.setFacebookProfilePicURL("faceboook.com/profile/pic")
profile.setLinkedInId("linkedinid")
profile.setTwitterId("twitterid")
// Add other custom fields
[profile setFieldName:@"mobilePhone"withValue:@"123.456.7890"];
[profile setFieldName:@"numberOfEmployees"withValue:@"10"];
[profile setFieldName:@"phone"withValue:@"123.456.7890"];
profile.setFieldName("mobilePhone" , withValue :"123.456.7890");
profile.setFieldName("numberOfEmployees", withValue: "10");
profile.setFieldName("phone", withValue:"123.456.7890");
Marketo *sharedInstance = [Marketo sharedInstance];
// This method will update user profile
[sharedInstance associateLead:profile];
let marketo = Marketo.sharedInstance()
// This method will update user profile
marketo.associateLead(profile)
#How to Send Custom Actions on iOS
Marketo *sharedInstance = [Marketo sharedInstance];
[sharedInstance reportAction:@"Login" withMetaData:nil];
MarketoActionMetaData *meta = [[MarketoActionMetaData alloc] init];
[meta setType:@"Shopping"];
[meta setDetails:@"RedShirt"];
[meta setLength:20];
[meta setMetric:30];
[sharedInstance reportAction:@"Bought Shirt" withMetaData:meta];
let meta = MarketoActionMetaData()
meta.setType("Shopping");
meta.setDetails("RedShirt");
meta.setLength(20);
meta.setMetric(30);
sharedInstance.reportAction("Bought Shirt", withMetaData:meta);
The Marketo SDK exposes 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. learn more about Advanced Security Access Mode here.
Marketo * sharedInstance =[Marketo sharedInstance];
// set secure signature
MKTSecuritySignature *signature =
[[MKTSecuritySignature alloc] initWithAccessKey:<ACCESS_KEY> signature:<SIGNATURE_TOKEN> timestamp:<EXPIRY_TIMESTAMP> email:<EMAIL>];
[sharedInstance setSecureSignature:signature];
[sharedInstance removeSecureSignature];
[sharedInstance getDeviceId];
let sharedInstance = Marketo.sharedInstance()
// set secure signature
let signature = MKTSecuritySignature(accessKey: <ACCESS_KEY>, signature: <SIGNATURE_TOKEN> , timestamp: <EXPIRY_TIMESTAMP>, email: <EMAIL>)
sharedInstance.setSecureSignature(signature)
[sharedInstance removeSecureSignature];
sharedInstance.getDeviceId()