Skip to content

Integrate the SDK with EMSAppDelegate

dschuppa edited this page Nov 14, 2019 · 4 revisions

Integrate the SDK with EMSAppDelegate

What is EMSAppDelegate?

We created an easier solution to integrate Emarsys SDK by inheriting from our EMSAppDelegate. We created EMSAppDelegate to make the integration of Emarsys SDK more convenient. By inheriting from this class every step of the setup process is handled by us.

Preconditions

Note

Please complete the required steps before proceeding

How it works

The only thing you have to do is to provide us an EMSConfig by the dedicated method which you have to implement.

Note

If you need to add something to the original AppDelegate methods, you simply have to override those methods and call super.

This results in a very simplified AppDelegate:

Objective-C
#import <Foundation/Foundation.h>
#import "EMSAppDelegate.h"

@interface AppDelegate : EMSAppDelegate

@end
#import "AppDelegate.h"
#import "EMSConfig.h"

@implementation AppDelegate

- (EMSConfig *)provideEMSConfig {
    EMSConfig *config = [EMSConfig makeWithBuilder:^(EMSConfigBuilder *builder) {
        [builder setContactFieldId:<contactFieldId: NSNumber>];
        [builder setMobileEngageApplicationCode:<applicationCode: NSString>];
        [builder setMerchantId:<predictMerchantId: NSString>];
    }];
    return config;
}
@end
Swift
import EmarsysSDK

@UIApplicationMain
class AppDelegate: EMSAppDelegate {

    override func provideEMSConfig() -> EMSConfig! {
        EMSConfig.make { builder in
            builder.setMobileEngageApplicationCode(<applicationCode: String>)
            builder.setContactFieldId(<contactFieldId: Number>)
            builder.setMerchantId(<predictMerchantId: String>)
        }
    }

}
Clone this wiki locally