-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
217 additions
and
326 deletions.
There are no files selected for viewing
This file contains 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
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 | ||
} | ||
} |
This file contains 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
This file contains 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
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 | ||
} | ||
}) |
This file contains 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
Oops, something went wrong.