License | MIT |
ReleasedLast Release | Feb 2017 |
Maintained by Bogdan Laukhin.
App Chains are the easy way to code Real Time Personalization (RTP) into your app.
Easily add an App-Chains
functionality using this CocoaPods plugin for iOS apps coded in Swift
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:
For 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.
set up File Selector plugin: File Selector plugin Swift (CocoaPods plugin)
configuration for App-Chains: 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>
AppChain module contains framework with encapsulated logic inside (build on Objective-C language). AppChains Swift API overview
Method | Purpose | Arguments | Description |
---|---|---|---|
init(token: String, withHostName: String) |
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 |
func getReportWithApplicationMethodName(applicationMethodName: String!, withDatasourceId: String!, withSuccessBlock: ((Report!) -> Void)!, withFailureBlock: ((NSError!) -> Void)!) |
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 |
|
func getBatchReportWithApplicationMethodName(appChainsParams: [AnyObject]!, withSuccessBlock: ReportsArray!, withFailureBlock: ((NSError!) -> Void)!) |
Reporting API with batch request |
appChainsParams - array of params for batch request. Each param should be an array with 2 items: first object - applicationMethodName last object - datasourceId success - callback executed on success operation, results with ReportsArray as 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:
first of all you need to create bridging header file. Select File > New > File > Header File > name it as
project-name-Bridging-Header.h
add AppChains class import in the bridging header file
#import <AppChainsLibrary/AppChains.h>
register your bridging header file in the project settings. Select your project > project target > Build Settings > Objective-C Bridging Header specify path for bridging header file
$(PROJECT_DIR)/project-name-Bridging-Header.h
After that you can start utilizing Reporting API for single chain request, example:
let appChainsManager = AppChains.init(token: accessToken as String, withHostName: "api.sequencing.com")
appChainsManager.getReportWithApplicationMethodName("Chain88", withDatasourceId: fileID, withSuccessBlock: { (result) in
let resultReport: Report = result as Report!
if resultReport.isSucceeded() {
if resultReport.getResults() != nil {
for item: AnyObject in resultReport.getResults() {
let resultObj = item as! Result
let resultValue: ResultValue = resultObj.getValue()
if resultValue.getType() == ResultType.Text {
print(resultObj.getName() + " = " + (resultValue as! TextResultValue).getData())
}
}
}
} else {
print("Error occured while getting genetic information")
}
}) { (error) in
print("Error occured while getting genetic information. " + error.localizedDescription)
}
Example of using batch request API for several chains:
let appChainsManager = AppChains.init(token: accessToken as String, withHostName: "api.sequencing.com")
let appChainsForRequest: NSArray = [["Chain88", fileID],
["Chain9", fileID]]
appChainsManager.getBatchReportWithApplicationMethodName(appChainsForRequest as [AnyObject], withSuccessBlock: { (resultsArray) in
let reportResultsArray = resultsArray as NSArray
for appChainReport in reportResultsArray {
let appChainReportDict = appChainReport as! NSDictionary
let resultReport: Report = appChainReportDict.objectForKey("report") as! Report;
let appChainID: NSString = appChainReportDict.objectForKey("appChainID") as! NSString;
if appChainID.isEqualToString("Chain88") {
appChainValue = self.parseReportForChain88(resultReport) // your own method to parse report object
print(appChainValue)
} else if appChainID.isEqualToString("Chain9") {
appChainValue = self.parseReportForChain9(resultReport) // your own method to parse report object
print(appChainValue)
}
}
}) { (error) in
print("batch request error. " + error.localizedDescription)
completion(appchainsResults: nil)
}
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.