Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
141 lines (118 sloc) 4.43 KB

Developer Chat Apache 2.0 License Objective-C/Swift Web Support


DigiMeSDK 3.x.x Migration Tips

Here are some key SDK changes that may help you get to grips with it if you are migrating from 2.x.x to 3.x.x versions:

  1. DMEClient singleton no longer exists. It has been replaced by DMEPullClient and DMEPushClient.

  2. In AppDelegate, you still need to forward app open events to the SDK. This is now done by forwarding the event to DMEAppCommunicator:

#####Objective-C

-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
	return [[DMEAppCommunicator shared] openURL:url options:options];
}

#####Swift

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
  return DMEAppCommunicator.shared().open(url, options: options)
}
  1. Each type of client has to be instantiated with a corresponding configuration object:

#####Objective-C

DMEPullConfiguration *configuration = [[DMEPullConfiguration alloc] initWithAppId:@"YOUR_APP_ID" contractId:@"YOUR_CONTRACT_ID" privateKeyHex: privateKeyHex];
DMEPullClient *pullClient = [[DMEPullClient alloc] initWithConfiguration:configuration];

#####Swift

let configuration = DMEPullConfiguration(appId: "YOUR_APP_ID", contractId: "YOUR_CONTRACT_ID", privateKeyHex: privateKeyHex)
let pullClient = DMEPullClient(configuration: configuration)
  1. We recommend you turn on debug logging while evaluating the SDK, which can be done via:

#####Objective-C

// this will add extra logging to the console.
configuration.debugLogEnabled = YES;

#####Swift

// this will add extra logging to the console.
configuration.debugLogEnabled = true
  1. We no longer support delegate based approach for SDK callbacks. Alternatives are:

#####Objective-C

//Begin auth flow
[pullClient authorizeWithCompletion:^(DMESession * _Nullable session, NSError * _Nullable error) {

  // if there's no error - you can now get accounts
  // and/or start downloading session data
}];

#####Swift

//Begin auth flow
pullClient.authorize(completion: { session, error in

  // if there's no error - you can now get accounts
  // and/or start downloading session data
})

#####Objective-C

//get accounts
[pullClient getSessionAccountsWithCompletion:^(DMEAccounts * _Nullable accounts, NSError * _Nullable error) {
	// do stuff
}];

#####Swift

//get accounts
pullClient.getSessionAccounts { accounts, error in
	// do stuff
}

#####Objective-C

//get session data
//NOTE: downloadHandler and completion are NOT executed on MAIN thread.
[pullClient getSessionDataWithDownloadHandler:^(DMEFile * _Nullable file, NSError * _Nullable error) {
  // this is called every time either:
  // A: new file has been downloaded
  // B: prevously downloaded file has been updated
  // In case B, full file is delivered NOT the change.
} completion:^(NSError * _Nullable error) {
  // this is called when all available session data has been retrieved.
}];

#####Swift

//get session data
//NOTE: downloadHandler and completion are NOT executed on MAIN thread.
pullClient.getSessionData(downloadHandler: { file, error in
  // this is called every time either:
  // A: new file has been downloaded
  // B: prevously downloaded file has been updated
  // In case B, full file is delivered NOT the change.
}, completion: { error in
  // this is called when all available session data has been retrieved.
})
You can’t perform that action at this time.