Skip to content

Commit

Permalink
update example app
Browse files Browse the repository at this point in the history
  • Loading branch information
Varnius committed Feb 17, 2021
1 parent a0d6b7e commit 1550ffc
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 326 deletions.
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
root: true,
extends: '@react-native-community',
};
rules: {
'prettier/prettier': 'warn',
'semi': 0
}
}
7 changes: 5 additions & 2 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ module.exports = {
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
};
semi: false,
quoteProps: 'consistent',
trailingComma: 'none',
printWidth: 120
}
194 changes: 88 additions & 106 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,127 +1,109 @@
/**
* Sample React Native App
*
* adapted from App.js generated by the following command:
*
* react-native init example
*
* https://github.com/facebook/react-native
*/

import React, { Component } from 'react';
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native'
import React, {Component} from 'react'
import {StyleSheet, Text, View, TouchableOpacity} from 'react-native'
import AsyncStorage from '@react-native-community/async-storage'

import ArgyleSdk from '@argyleio/argyle-plugin-react-native'

const TOKEN_KEY = "userKey"
const TOKEN_KEY = 'userKey'

storeData = async (token) => {
try {
await AsyncStorage.setItem(TOKEN_KEY, token)
} catch (e) {
// saving error
console.log("error saving value", e)
}
const storeData = async token => {
try {
await AsyncStorage.setItem(TOKEN_KEY, token)
} catch (e) {
// saving error
console.log('error saving value', e)
}
}

getData = async () => {
try {
const value = await AsyncStorage.getItem(TOKEN_KEY)
if (value !== null) {
// value previously stored
}
return value
} catch (e) {
// error reading value
console.log("error reading value", e)
return null
const getData = async () => {
try {
const value = await AsyncStorage.getItem(TOKEN_KEY)
if (value !== null) {
// value previously stored
}
return value
} catch (e) {
// error reading value
console.log('error reading value', e)
return null
}
}
export default class App extends Component<{}> {
state = {
status: 'starting',
message: '--'
}
async componentDidMount() {
let token = ''
const value = await getData()

async componentDidMount() {
let token = ""
const value = await getData()
console.log('VALUE ', value)

console.log("VALUE ", value)
if (value !== null) {
token = value
}

if (value !== null) {
token = value
}
ArgyleSdk.loginWith('YOUR_PLUGIN_KEY', 'https://api-sandbox.argyle.io', token)
ArgyleSdk.onUserCreated(res => {
console.log('onUserCreated', res)
storeData(res.token)
})

ArgyleSdk.loginWith("YOUR_PLUGIN_KEY", "https://api-sandbox.argyle.io", token)
ArgyleSdk.onUserCreated(res => {
console.log("onUserCreated", res)
storeData(res.token)
})
ArgyleSdk.onAccountCreated(res => console.log('onAccountCreated', res))
ArgyleSdk.onAccountConnected(res => console.log('onAccountConnected', res))
ArgyleSdk.onAccountUpdated(res => console.log('onAccountUpdated', res))
ArgyleSdk.onAccountRemoved(res => console.log('onAccountRemoved', res))
ArgyleSdk.onAccountError(res => console.log('onAccountError', res))
ArgyleSdk.onError(error => {
console.log('onError', error)
if (error === ArgyleSdk.errorCodes.EXPIRED_TOKEN) {
setTimeout(() => {
// Simulated timeout before updating the token
ArgyleSdk.updateToken('YOUR_NEW_TOKEN')
}, 300)
}
})
ArgyleSdk.onTokenExpired(res => console.log('onTokenExpired', res))
ArgyleSdk.onClose(() => console.log('onClose'))

ArgyleSdk.onAccountCreated(res => console.log("onAccountCreated", res))
ArgyleSdk.onAccountConnected(res => console.log("onAccountConnected", res))
ArgyleSdk.onAccountUpdated(res => console.log("onAccountUpdated", res))
ArgyleSdk.onAccountRemoved(res => console.log("onAccountRemoved", res))
ArgyleSdk.onAccountError(res => console.log("onAccountError", res))
ArgyleSdk.onError(error => {
console.log("onError", error)
if (error === ArgyleSdk.errorCodes.EXPIRED_TOKEN) {
setTimeout(() => {
// Simulated timeout before updating the token
ArgyleSdk.updateToken("YOUR_NEW_TOKEN")
}, 300)
}
})
ArgyleSdk.onTokenExpired(res => console.log("onTokenExpired", res))
ArgyleSdk.onClose(() => console.log("onClose"))
// ArgyleSdk.dataPartners(["uber", "postmates"])
}

// ArgyleSdk.dataPartners(["uber", "postmates"])
}
startNew = () => {
ArgyleSdk.updateToken('')
ArgyleSdk.start()
}

startNew = () => {
ArgyleSdk.updateToken("")
ArgyleSdk.start()
}

startExisting = async () => {
ArgyleSdk.start()
}
startExisting = async () => {
ArgyleSdk.start()
}

render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>☆ARArgyleSdk example☆</Text>
<Text style={styles.instructions}>STATUS: {this.state.status}</Text>
<Text style={styles.welcome}>☆NATIVE CALLBACK MESSAGE☆</Text>
<Text style={styles.instructions}>{this.state.message}</Text>
<TouchableOpacity onPress={this.startNew}>
<Text style={styles.welcome}>Start new</Text>
</TouchableOpacity>
<TouchableOpacity onPress={this.startExisting}>
<Text style={styles.welcome}>Start existing</Text>
</TouchableOpacity>
</View>
);
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>📱️ Argyle Link SDK️</Text>
<TouchableOpacity onPress={this.startNew}>
<Text style={styles.welcome}>Start new</Text>
</TouchableOpacity>
<TouchableOpacity onPress={this.startExisting}>
<Text style={styles.welcome}>Start existing</Text>
</TouchableOpacity>
</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,
},
});
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF'
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5
}
})
8 changes: 4 additions & 4 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ target 'tester' do
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
# use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end
end

target 'tester-tvOS' do
Expand Down
Loading

0 comments on commit 1550ffc

Please sign in to comment.