content: 
  import React, { Component } from 'react';
  import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Button,
    Fetch,
    AsyncStorage,
    DeviceEventEmitter
  } from 'react-native';
  
  export default class RApp extends Component {
  
  	constructor(props) {
  		super(props);
  		this.IPAddress = '192.168.1.1';
  		try {
  		  AsyncStorage.getItem('@store:ip').then((value) => {
  		  	if(value != null) {
  		  		console.log(this.IPAddress);
  		  		this.IPAddress = value;
  		  	}
  		  })
  		} catch (error) {
  			console.log(error);
  		}
  		this.checkConnection = this.checkConnection.bind(this);
  		this.findHost = this.findHost.bind(this);
  	}
  
  	componentDidMount() {
  		DeviceEventEmitter.addListener('link', function(e: Event) {
  	    	this.sendCommand.bind(this, {command: 'openlink', link: e})();
  	  }.bind(this));
  	}
  
  
  	async checkConnection() {
  		console.log(this.IPAddress);
  		try {
  			let response = await fetch('http://' + this.IPAddress + '/motion?phrase=marco' , {
  				method: 'GET'
  			})
  			if(response.status !== 200) {
  				return false;
  			}
  			let responseJson = await response.json();
  			console.log(responseJson);
  			if(responseJson.phrase !== 'polo') {
  				return false;
  			}
  			return true;
  		} catch(error) {
  			console.log(error);
  		}
  
  	}
  
  	findHost() {
  		var initialIP = '192.168.1.';
  		var found = false;
  		console.log('finding');
  		for(var i = 0;i < 256;i++) {     
  			if(found) {
  				break;  
  			}
  			fetch('http://' + initialIP + i + '/motion?phrase=marco', {
  				method: 'GET',
  				timeout: 100
  			})
  			.then((response) => {
  				if(response.status === 200) {
  					return response.json();
  				}
  			})
  			.then((responseData) => {
  				if(responseData.phrase === 'polo') {
  					found = true;
  					console.log(responseData.ip);
  					this.IPAddress = responseData.ip;
  					AsyncStorage.setItem('@store:ip', responseData.ip);
  				}
  			})
  			.catch((error) => {
  
  			})	
  		}
  	}
  
  
  
  	async sendCommand(commandObj) {
  		let connectionAlive = await this.checkConnection();
  		console.log(connectionAlive);
  		if(!connectionAlive) {
  			this.findHost();
  			return;
  		}
  		fetch('http://' + this.IPAddress + '/command', {   
  			method: 'POST',
  			 headers: {
  			     'Content-Type': 'application/json',
  			 },
  			body: JSON.stringify(commandObj)
  		})
  		.then((response) => {
  			//console.log(response)
  		})
  		.catch((error) => {
  			console.log(error);
  		})
  	}
  
    render() {
      return (
        <View style={styles.container}>
        	<View style={styles.buttonView}>
          	<Button title="Screen on" onPress={this.sendCommand.bind(this, {command: 'scron'})}/>
          </View>
          <View style={styles.buttonView}>
          	<Button title="Screen off" onPress={this.sendCommand.bind(this, {command: 'scroff'})}/>
          </View>
          <View style={styles.buttonView}>
          	<Button title="Volume+" onPress={this.sendCommand.bind(this, {command: 'volup'})}/>
          </View>
          <View style={styles.buttonView}>
          	<Button title="Volume-" onPress={this.sendCommand.bind(this, {command: 'voldown'})}/>
          </View>
          <View style={styles.buttonView}>
          	<Button title="Volume mute" onPress={this.sendCommand.bind(this, {command: 'volmute'})}/>
          </View>
          <View style={styles.buttonView}>
          	<Button title="Shutdown" onPress={this.sendCommand.bind(this, {command: 'shutdown'})}/>
          </View>
        </View>
      );
    }
  }
  
  const styles = StyleSheet.create({
    container: {
      flex: 1,
      
      alignItems: 'center',
      backgroundColor: '#F5FCFF',
    },
    buttonView: {
    	width: '100%',
    	marginBottom: 10,
    	marginTop: 10
    },
  
  });
  
  AppRegistry.registerComponent('RApp', () => RApp);
  