1

I am in need of Initialising WebEngage SDK based on some conditions.

if condition {
//initialise with `X` Account ID
} else {
//initialise with `Y` Account ID
}

But as per WebEnage-Documentation there is no method for initialising SDK with accountId. we just call below code in our AppDelegate's didFinishLaunchingWithOptions method.

WebEngage.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

and it initialise the SDK by reading account id from info.plist file. I tried updating Info.plist at run time but that didn't work. I am looking for the right approach to do it.

Ashwani Kumar
  • 465
  • 4
  • 9
  • What's `condition` Is it a Swift Flag? If so, you could have different plist for each scheme? See https://stackoverflow.com/questions/27548496/how-can-i-change-plist-entries-based-on-my-scheme Else, maybe an env file, and filling the plist values with them with a script on build? – Larme Sep 28 '22 at 10:45
  • @Larme he is looking for run time solution. – Abin George Sep 29 '22 at 06:36
  • 2
    If by "account", you mean the `WEGLicenseCode`, then there is a method available apparently to do so: `-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions setLicenseCode:(NSString *)licenseCode;` – Larme Sep 29 '22 at 07:54

1 Answers1

0

In WebEngage v6.0.0 a new initialising method is introduced that can have licenseCode as parameter.

func application(_ application: UIApplication?, didFinishLaunchingWithOptions launchOptions: [AnyHashable : Any]?, notificationDelegate: WEGInAppNotificationProtocol?, autoRegister apnRegister: Bool, setLicenseCode licenseCode: String?) -> Bool

I initialises SDK with help of above method in AppDelegate's didFinishLaunchingWithOptions method.

if staging {
   WebEngage.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions, setLicenseCode: "xyz")
} else {
   WebEngage.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions, setLicenseCode: "abc")
}
Ashwani Kumar
  • 465
  • 4
  • 9