Coder Social home page Coder Social logo

sequencingdotcom / rtp-api-cocoapod-ios-app-chains-objectivec Goto Github PK

View Code? Open in Web Editor NEW
0.0 6.0 0.0 31 KB

Easily add App Chains to your app using this CocoPod plugin for ObjectiveC iOS apps

License: MIT License

Objective-C 91.81% Ruby 8.19%

rtp-api-cocoapod-ios-app-chains-objectivec's Introduction

CocoaPod-iOS-App-Chains-ObjectiveC

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

Contents

  • Introduction
  • Example (of an app using RTP)
  • CocoaPod integration
  • Configuration
  • Troubleshooting
  • Resources
  • Maintainers
  • Contribute

Introduction

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:

  1. API call
  • API call that triggers an app hosted by Sequencing.com to perform genetic analysis on your app user's genes
  1. API response
  • the straightforward, easy-to-use results are sent to your app as the API response
  1. Personalzation
  • your app uses this information, which is obtained directly from your app user's genes in real-time, to create a truly personalized user experience

Each app chain is composed of

  • an API request to Sequencing.com
  • this request is secured using oAuth2
  • analysis of the app user's genes
  • each app chain analyzes a specific trait or condition
  • there are thousands of app chains to choose from
  • all analysis occurs in real-time at Sequencing.com
  • an API response to your app
  • the information provided by the response allows your app to tailor itself to the app user based on the user's genes.
  • the documentation for each app chain provides a list of all possible API responses. The response for most app chains are simply 'Yes' or 'No'.

Example

  • App Chain: It is very important for this person's health to apply sunscreen with SPF +30 whenever it is sunny or even partly sunny.
  • Possible responses: Yes, No, Insufficient Data, Error

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.

Example

What types of apps can you personalize with app chains? Any type of app... even a weather app.

  • The open source Weather My Way +RTP app differentiates itself from all other weather apps because it uses app chains to provide genetically tailored content in real-time to each app user.
  • Experience it yourself using one of the fun sample genetic data files. These sample files are provided for free to all apps that use app chains.

CocoaPod integration

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
    

Configuration

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>

  • replace with the oAuth2 secret obtained from your Sequencing.com account

  • The code snippet for enabling Sequencing.com's oAuth2 authentication for your app can be found in the oAuth2 code and demo repo

  • <chain id>

  • replace with the App Chain ID obtained from the list of App Chains

  • <file id>

  • replace with the file ID selected by the user while using your app

  • The code snippet for enabling Sequencing.com's File Selector for your app can be found in the File Selector code repo

Objective-C

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 object

failure - 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 string
report - Report object

failure - callback executed on operation failure

Adding code to the project:

  • import AppChains: #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) {

			for (Result *obj in [result getResults]) {
				ResultValue *frv = [obj getValue];
				if ([frv getType] == kResultTypeText) {
					NSLog(@"\nvalue %@ = %@\n", [obj getName], [(TextResultValue *)frv getData]);
				}
			}
        }
        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 = @[
		@[@"<chain id>", @"<file id>"], 
		@[@"<chain id>", @"<file id>"]
		];
    
[appChains getBatchReportWithApplicationMethodName:appChainsForRequest
		withSuccessBlock:^(NSArray *reportResultsArray) {
			
			// @reportResultsArray - result of reports (Report object) 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"];
				
				NSLog(@"\n\n appChainID: %@\n", appChainID);
				
				for (Result *obj in [result getResults]) {
					ResultValue *frv = [obj getValue];
					if ([frv getType] == kResultTypeText) {
						NSLog(@"\nvalue %@ = %@\n", [obj getName], [(TextResultValue *)frv getData]);
					}
				}
			}
		}
		withFailureBlock:^(NSError *error) {
			NSLog(@"batch request error: %@", error);
		}];

Troubleshooting

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:
  1. <your token>
  1. <chain id>
  • replace with the App Chain ID obtained from the list of App Chains
  1. <file id>
  • replace with the file ID selected by the user while using your app.

  • The code snippet for enabling Sequencing.com's File Selector for your app can be found in the File Selector code repo

  • Developer Documentation

  • oAuth2 guide

  • 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.

Resources

Maintainers

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.

Contribute

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.