TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Mar 2017 |
Maintained by Bogdan Laukhin, Alex Moskvin.
App Chains are the easy way to code Real Time Personalization (RTP) into your app. Easily add an App-Chains functionality using this CocoaPod plugin for ObjectiveC iOS apps
Search and find app chains -> https://sequencing.com/app-chains/
An app chain is an integration of an API call and an analysis of an app user's genes. Each app chain provides information about a specific trait, condition, disease, supplement or medication. App chains are used to provide genetically tailored content to app users so that the user experience is instantly personalized at the genetic level. This is called Real Time Personalization (RTP).
Each app chain consists of:
Each app chain is composed of
Example
While there are already app chains to personalize most apps, if you need something but don't see an app chain for it, tell us! (ie email us: [email protected]).
To code Real Time Personalization (RTP) technology into apps, developers may register for a free account at Sequencing.com. App development with RTP is always free.
What types of apps can you personalize with app chains? Any type of app... even a weather app.
Please follow this guide to install App-Chain module in your existed or new project
see general CocoaPods instruction: https://cocoapods.org > getting started
create a new project in Xcode
create Podfile in your project directory:
$ pod init
specify sequencing-app-chains-api-objc
pod parameters in Podfile:
pod 'sequencing-app-chains-api-objc', '~> 1.1.1'
install the dependency in your project:
$ pod install
always open the Xcode workspace instead of the project file:
$ open *.xcworkspace
There are no strict configurations that have to be performed.
Just drop the source files for an app chain into your project to add Real-Time Personalization to your app.
Code snippets below contain the following three placeholders. Please make sure to replace each of the placeholders with real values:
<your token>
<chain id>
<file id>
AppChains Objective-C API overview
Method | Purpose | Arguments | Description |
---|---|---|---|
- (instancetype)initWithToken:(NSString *)token |
Constructor | token - security token provided by sequencing.com | |
- (instancetype)initWithToken:(NSString *)token withHostName:(NSString *)hostName |
Constructor |
token - security token provided by sequencing.com hostName - API server hostname. api.sequencing.com by default |
Constructor used for creating AppChains class instance in case reporting API is needed and where security token is required |
- (void)getReportWithApplicationMethodName:(NSString *)applicationMethodName withDatasourceId:(NSString *)datasourceId withSuccessBlock:(void (^)(Report *result))success withFailureBlock:(void (^)(NSError *error))failure; |
Reporting API |
applicationMethodName - name of data processing routine datasourceId - input data identifier success - callback executed on success operation, results with Report objectfailure - callback executed on operation failure |
|
- (void)getBatchReportWithApplicationMethodName:(NSArray *)appChainsParams withSuccessBlock:(ReportsArray)success withFailureBlock:(void (^)(NSError *error))failure; |
Reporting API with batch request |
appChainsParams - array of params for batch request. Each param should be an array with items: first object - applicationMethodName last object - datasourceId success - callback executed on success operation, results with array of dictionaries. Each dictionary has following keys and objects: appChainID - appChain ID stringreport - Report objectfailure - callback executed on operation failure |
Adding code to the project:
#import "AppChains.h"
After that you can start utilizing Reporting API for single chain request:
AppChains *appChains = [[AppChains alloc] initWithToken:yourAccessToken withHostName:@"api.sequencing.com"];
[appChains getReportWithApplicationMethodName:@"<chain id>"
withDatasourceId:@"<file id>"
withSuccessBlock:^(Report *result) {
NSArray *arr = [result getResults];
for (Result *obj in arr) {
ResultValue *frv = [obj getValue];
if ([frv getType] == kResultTypeFile)
[(FileResultValue *)frv saveToLocation:@"/tmp/"];
}
}
withFailureBlock:^(NSError *error) {
NSLog(@"Error occured: %@", [error description]);
}];
Example of using batch request API for several chains:
AppChains *appChains = [[AppChains alloc] initWithToken:yourAccessToken withHostName:@"api.sequencing.com"];
// parameters array for batch request as example
NSArray *appChainsForRequest = @[@[@"Chain88", fileID], @[@"Chain9", fileID]];
[appChains getBatchReportWithApplicationMethodName:appChainsForRequest
withSuccessBlock:^(NSArray *reportResultsArray) {
// @reportResultsArray - result of reports for batch request, it's an array of dictionaries
// each dictionary has following keys: "appChainID": appChainID string, "report": *Report object
for (NSDictionary *appChainReportDict in reportResultsArray) {
Report *result = [appChainReportDict objectForKey:@"report"];
NSString *appChainID = [appChainReportDict objectForKey:@"appChainID"];
NSString *appChainValue = [NSString stringWithFormat:@""];
if ([appChainID isEqualToString:@"Chain88"])
appChainValue = [self parseAndHandleReportForChain88:result]; // your own method to parse report object
else if ([appChainID isEqualToString:@"Chain9"])
appChainValue = [self parseAndHandleForChain9:result]; // your own method to parse report object
}
}
withFailureBlock:^(NSError *error) {
NSLog(@"batch request error: %@", error);
}];
Each app chain code should work straight out-of-the-box without any configuration requirements or issues.
Other tips
Ensure that the following three placeholders have been substituted with real values:
<your token>
<chain id>
<file id>
Review the Weather My Way +RTP app, which is an open-source weather app that uses Real-Time Personalization to provide genetically tailored content
Confirm you have the latest version of the code from this repository.
This repo is actively maintained by Sequencing.com. Email the Sequencing.com bioinformatics team at [email protected] if you require any more information or just to say hola.
We encourage you to passionately fork us. If interested in updating the master branch, please send us a pull request. If the changes contribute positively, we'll let it ride.