1

I am trying to initialise in Objective-C.

In Swift the method is:

[SFMCSdk initializeSdk: ConfigBuilder().setPush(config: mobilePushConfiguration, onCompletion: completionHandler).build()];

But it could not initialise with Objective-C.

Before updated the library, the method is:

[[MarketingCloudSDK sharedInstance] sfmc_configureWithDictionary:[builder sfmc_build] error:&error];

Can anyone help to write this method in Objective-C?!

1 Answer 1

1

First you need to create pushConfigBuilder and build the PushConfig. Then initialize the sdk as shown below:

  PushConfigBuilder *pushConfigBuilder = [[PushConfigBuilder alloc] initWithAppId:@""];
    pushConfigBuilder = [pushConfigBuilder setAccessToken:@""];
    pushConfigBuilder =  [pushConfigBuilder setMarketingCloudServerUrl:[NSURL URLWithString:@""]];
    pushConfigBuilder = [pushConfigBuilder setMid:@""];
    pushConfigBuilder = [pushConfigBuilder setAnalyticsEnabled:YES];
    pushConfigBuilder = [pushConfigBuilder setInboxEnabled:YES];
    pushConfigBuilder = [pushConfigBuilder setLocationEnabled:YES];
    pushConfigBuilder = [pushConfigBuilder setEnableScreenEntryTracking:NO];
    PushConfig *pushConfig = [pushConfigBuilder build];
    
    void (^completionHandler)(OperationResult) = ^(OperationResult result) {
        switch(result) {
            case OperationResultError:
                break;
            case OperationResultSuccess:
                break;
            default:
                break;
        }
    };
    
    
    SFMCSdkConfigBuilder *configBuilder = [[SFMCSdkConfigBuilder alloc] init];
    configBuilder = [configBuilder setPushWithConfig:pushConfig onCompletion:completionHandler];
    
    
    [SFMCSdk initializeSdk:[configBuilder build]];

Thanks, Prakashini

1
  • Thanks for this answer.But When I use this it is jump in "OperationResultTimeout". How can this will be successfully initialised. Jul 26, 2022 at 14:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .