DUIX ONE-Offline iOS SDK is a local version of the DUIX ONE SDK that provides offline capabilities. It allows developers to integrate DUIX's AI capabilities into iOS applications without requiring an internet connection.
Add the following to your Podfile:
platform :ios, '11.0'
target 'YourApp' do
use_frameworks!
# DUIX ONE-Offline SDK
pod 'DuixOfflineSDK', '~> x.x.x'
end
Replace x.x.x
with the latest version of the SDK.
Then run:
pod install
Add the package dependency to your Package.swift file:
dependencies: [
.package(url: "https://github.com/duix/duix-offline-ios.git", .upToNextMajor(from: "x.x.x"))
]
Or add it directly in Xcode: File > Swift Packages > Add Package Dependency
Initialize the SDK in your AppDelegate:
import DuixOfflineSDK
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize DUIX ONE-Offline SDK
let config = DuixOfflineConfig(appId: "your_app_id", appKey: "your_app_key")
DuixOfflineSDK.initialize(with: config)
return true
}
}
#import <DuixOfflineSDK/DuixOfflineSDK.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Initialize DUIX ONE-Offline SDK
DuixOfflineConfig *config = [[DuixOfflineConfig alloc] initWithAppId:@"your_app_id" appKey:@"your_app_key"];
[DuixOfflineSDK initializeWithConfig:config];
return YES;
}
@end
The main entry point for the SDK.
// Initialize SDK
DuixOfflineSDK.initialize(with: config)
// Check if SDK is initialized
let isInitialized = DuixOfflineSDK.isInitialized()
// Get SDK version
let version = DuixOfflineSDK.version()
// Initialize SDK
[DuixOfflineSDK initializeWithConfig:config];
// Check if SDK is initialized
BOOL isInitialized = [DuixOfflineSDK isInitialized];
// Get SDK version
NSString *version = [DuixOfflineSDK version];
Configuration class for the SDK.
let config = DuixOfflineConfig(
appId: "your_app_id",
appKey: "your_app_key",
debugMode: true,
logLevel: .verbose
)
DuixOfflineConfig *config = [[DuixOfflineConfig alloc] initWithAppId:@"your_app_id"
appKey:@"your_app_key"];
config.debugMode = YES;
config.logLevel = DuixLogLevelVerbose;
// Create text recognizer
let recognizer = DuixOfflineSDK.createTextRecognizer()
// Recognize text from image
recognizer.recognizeText(from: image) { result, error in
if let error = error {
// Handle error
let code = error.code
let message = error.message
} else if let result = result {
// Handle success
let text = result.text
}
}
// Release resources when done
recognizer.release()
// Create text recognizer
DuixTextRecognizer *recognizer = [DuixOfflineSDK createTextRecognizer];
// Recognize text from image
[recognizer recognizeTextFrom:image completion:^(DuixTextRecognitionResult *result, DuixError *error) {
if (error) {
// Handle error
NSInteger code = error.code;
NSString *message = error.message;
} else {
// Handle success
NSString *text = result.text;
}
}];
// Release resources when done
[recognizer release];
// Create image classifier
let classifier = DuixOfflineSDK.createImageClassifier()
// Classify image
classifier.classify(image) { result, error in
if let error = error {
// Handle error
} else if let result = result {
// Handle success
let classifications = result.classifications
}
}
// Release resources when done
classifier.release()
// Create image classifier
DuixImageClassifier *classifier = [DuixOfflineSDK createImageClassifier];
// Classify image
[classifier classifyImage:image completion:^(DuixClassificationResult *result, DuixError *error) {
if (error) {
// Handle error
} else {
// Handle success
NSArray<DuixClassification *> *classifications = result.classifications;
}
}];
// Release resources when done
[classifier release];
Code | Description |
---|---|
1001 | SDK not initialized |
1002 | Invalid parameters |
1003 | License expired |
2001 | Model loading failed |
2002 | Processing error |
3001 | Out of memory |
3002 | Internal error |
Resource Management: Always release resources when you're done using them to prevent memory leaks.
Error Handling: Implement proper error handling to provide a good user experience.
Performance Optimization:
Battery Efficiency: Minimize continuous processing to conserve battery life.
Memory Management: Be mindful of memory usage, especially when processing large images or videos.
Q: How large are the offline models?
A: The size of offline models varies depending on the features you use, typically ranging from 10MB to 100MB.
Q: Can I use the SDK without an internet connection?
A: Yes, once the SDK is properly initialized and the models are downloaded, it can function completely offline.
Q: Does the SDK support iPad?
A: Yes, the SDK fully supports iPad devices running iOS 11.0 or later.
Q: How often are the offline models updated?
A: We release model updates quarterly, but you can continue using existing models indefinitely.
Q: Is there a limit to the number of API calls in offline mode?
A: No, there are no API call limits in offline mode, but there may be device performance limitations.
For technical support, please contact us at support@duix.com or visit our developer portal at https://developer.duix.com.