The BoneMobile container Software Development Kit (SDK) is an optional module that enables you to load plugins. To develop or use plugins, you must integrate the BoneMobile container SDK into your app.
Dependent SDKs | Overview |
Log | A basic dependent SDK that provides unified client-side log printing, log level control, and module-based log isolation. |
API channel | Enables API Gateway HTTPS requests that are encapsulated with IoT service protocols. |
MJRefresh | An open source pull-to-refresh control from GitHub. Version: 3.1.15. |
ZipArchive | An open source ZIP decompression library from GitHub. Version: 1.4.0. |
On August 1, 2019, Google Play stopped supporting apps that do not support the 64-bit architecture. If your app is listed on Google Play stores outside China and uses the BoneKit SDK, you must upgrade the SDK as soon as possible to avoid listing issues. Future plugins and upgrades will only support proprietary apps that have been upgraded to BoneKit SDK v0.59.
Initialization
To initialize the SDK, see SDK Initialization.
Usage
Open a UIViewController using routing
#import <IMSRouter/IMSRouter.h> NSURL *url = [NSURL URLWithString:@"link://router/{routerName}"]; NSDictionary *para = @{@"key": @"value"}; [[IMSRouterService sharedService] openURL:url options:para completionHandler:^(BOOL success) { if (success) { NSLog(@"Plugin opened successfully"); } else { NSLog(@"Failed to open plugin"); } }];Open a plugin panel and receive its return value
The following example shows how to call a network configuration plugin and accept the returned configuration.
#import <IMSRouter/IMSRouter.h> NSURL *url = [NSURL URLWithString:@"link://router/connectConfig"]; NSDictionary *para = @{AKRouterCompletionHandlerKey: ^(NSError *error, NSDictionary *result) { // result handler }}; [[IMSRouterService sharedService] openURL:url options:para completionHandler:^(BOOL success) { if (success) { NSLog(@"Plugin opened successfully"); } else { NSLog(@"Failed to open plugin"); } }];Open a UIViewController directly
#import <IMSBoneKit/BoneRCTViewController.h> NSURL *url = [NSURL URLWithString:@"{Plugin URL}"]; NSDictionary *para = @{@"key": @"value"}; BoneRCTViewController *controller = [BoneRCTViewController new]; [controller openUrl:newURL props:params]; [self.navigationController pushViewController:controller animated:YES];Open a UIViewController in local debug mode
To debug, you can use the debug version of the ReactNative library, which displays the debug menu. Modify the Podfile file as follows.
#pod 'AKReactNative', '0.41.2' pod 'AKReactNative', '0.41.2-debug' # This is the debug version. Do not use this version for apps submitted to the App Store.The following code provides an example.
__weak typeof(self) wSelf = self; NSURLSession *session = [NSURLSession sharedSession]; NSString *host = @"/*IP address of the computer where the Bone service is enabled*/"; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@:8081/boneDebugUrl?platform=ios&ip=%@", host, host]]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ if (!error) { NSDictionary *responseJSON = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil]; int responseCode = [[responseJSON objectForKey:@"code"] intValue]; if (responseCode == 200) { NSDictionary *responseData= [responseJSON objectForKey:@"data"]; NSString *urlString = responseData[@"url"]; BoneRCTViewController *controller = [BoneRCTViewController new]; [controller openUrl:[NSURL URLWithString:urlString] props:[responseData mutableCopy]]; controller.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:controller animated:YES]; } } }); }]; [task resume];
Integrate account features
BoneKit supports account plugins to enable custom account access. To integrate this feature, you must implement the IMSAccountProtocol and IMSAccountUIProtocol protocols. Then, set the IMSAccountService sessionProvider and accountProvider. If you use OpenAccount for account integration, refer to the implementation of IMSOpenAccount in the account demo.
The following code provides an example.
// Import the header file.
#import <IMSAccount/IMSAccountService.h>
IMSOpenAccount *openAccount = [IMSOpenAccount sharedInstance];
[IMSAccountService sharedService].sessionProvider = openAccount;
[IMSAccountService sharedService].accountProvider = openAccount;Share configurations between Native and JS
In some scenarios, native and JS clients need to share configurations. A shared configuration area that both clients can access is available for this purpose.
To access the configuration area from the JS client, refer to Environment configuration information.
To access the configuration area from the iOS client, use the following code.
// Set [[IMSBoneConfiguration sharedInstance] set:@"region" value:@"china"]; // Get [[IMSBoneConfiguration sharedInstance] get:@"region"];