-
-
Save CharlesGrimont/728d57b92a0666393051cc8ad36459dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
Platform, | |
StyleSheet, | |
Text, | |
View, | |
Button, | |
Alert, | |
DeviceEventEmitter, | |
NativeEventEmitter, | |
NativeModules | |
} from 'react-native'; | |
import {C8oSettings, C8o, C8oLogLevel} from "react-native-c8osdk"; | |
/* | |
var C8o = NativeModules.C8o; | |
var c8o = require("react-native-c8o-sdk/c8oSettings"); | |
var c8oSettings = require("react-native-c8o-sdk/c8oSettings"); | |
var C8oSettings = NativeModules.C8oSettings; | |
var C8oLogLevel = NativeModules.C8oLogLevel; | |
*/ | |
const instructions = Platform.select({ | |
ios: 'Press Cmd+R to reload,\n' + | |
'Cmd+D or shake for dev menu', | |
android: 'Double tap R on your keyboard to reload,\n' + | |
'Shake or press menu button for dev menu', | |
}); | |
/*const { C8oReact } = NativeModules; | |
const C8oManagerEmitter = new NativeEventEmitter(C8oReact); | |
const subscription = C8oManagerEmitter.addListener( | |
'progress', | |
(progress)=> console.log("Event emiter react Native: " + JSON.stringify(progress)) | |
); | |
*/ | |
type Props = {}; | |
export default class App extends Component<Props> { | |
state = { | |
data:"" | |
}; | |
c8o; | |
constructor(props) { | |
super(props); | |
let settings = new C8oSettings(); | |
settings.setTimeout(3000).setDefaultDatabaseName("edailycheck").setTrustAllCertificates(true).setLogLevelLocal(C8oLogLevel.TRACE); | |
this.c8o = new C8o(); | |
// Calling init method | |
this.c8o.init("https://poc.convertigo.net:443/cems/projects/eDailyCheck", settings); | |
} | |
componentDidMount() { | |
DeviceEventEmitter.addListener("Progress", (status)=> { | |
this.setState({data: status}) | |
}); | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Text style={styles.welcome}> | |
Welcome to React Native! | |
</Text> | |
<Text style={styles.instructions}> | |
To get started, edit App.js | |
</Text> | |
<Text style={styles.instructions}> | |
{instructions} | |
</Text> | |
<Text style={styles.instructions}> | |
{this.state.data} | |
</Text> | |
<Button title="Login and Sync" onPress={async ()=> { | |
var callReset = await this.c8o.callJson('fs://.reset'); | |
var result = await this.c8o.callJson('.login', { | |
login: "barnett.christinet", | |
password: "barnett.christine" | |
}); | |
this.setState({data: JSON.stringify(result)}); | |
var callReset = await this.c8o.callJson('fs://.reset'); | |
this.setState({data: JSON.stringify(callReset)}); | |
var resultLogin = await this.c8o.callJson("fs://.replicate_pull", {}); | |
console.log(resultLogin); | |
this.setState({data: JSON.stringify(resultLogin)}); | |
} | |
}/> | |
<Button title="Query" onPress={async ()=> { | |
try{ | |
var res = await this.c8o.callJson("fs://.view", {ddoc: "views", view: "airport"}); | |
this.setState({data: JSON.stringify(res.rows)}); | |
console.log(res); | |
} | |
catch(e){ | |
console.log("here"); | |
} | |
}}/> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center', | |
backgroundColor: '#F5FCFF', | |
}, | |
welcome: { | |
fontSize: 20, | |
textAlign: 'center', | |
margin: 10, | |
}, | |
instructions: { | |
textAlign: 'center', | |
color: '#333333', | |
marginBottom: 5, | |
}, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PofFile | |
# Uncomment the next line to define a global platform for your project | |
platform :ios, '9.0' | |
target 'ConvertigoProject' do | |
use_frameworks! | |
# Pods for C8oReact | |
pod 'SwiftyJSON', '4.0.0' | |
pod 'Alamofire', '4.7.2' | |
pod 'AEXML', '4.3.0' | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Repo | |
https://github.com/convertigo/c8osdk-ios |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment