-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
93 lines (85 loc) · 2.23 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React, { Component } from 'react';
import { StyleSheet, View, TouchableOpacity, Text } from 'react-native';
import { SmartClient, WeakClient, services } from 'zetapush-js';
const sandboxId = '';
const email = 'imth';
const password = 'azerty';
export default class App extends Component {
onPressCreateUser = () => {
const client = new WeakClient({ sandboxId });
client.connect();
client.onSuccessfulHandshake(() => {
client
.createService({
Type: services.Macro,
listener: {
createUser({ data }) {
if (data.errors.length) {
console.warn(data.errors[0].code);
} else {
console.warn("User created");
}
},
},
})
.call({
name: 'createUser',
parameters: {
login: email,
password,
fields: {
email,
firstName: 'Immersive',
lastName: 'Therapy',
addressLine1: 'imth',
zipCode: '35000',
city: 'Rennes',
country: 'France',
},
},
});
});
}
onPressConnect = () => {
const client = new SmartClient({ sandboxId });
client.setCredentials({ login: email, password });
client.connect();
client.onFailedHandshake(data => {
console.warn(data);
});
client.onSuccessfulHandshake((data) => {
console.warn('IT WORKS!!!', data);
});
}
render() {
return (
<View style={styles.container}>
<TouchableOpacity onPress={this.onPressCreateUser} style={styles.button}>
<Text style={styles.text}>CREATE USER</Text>
</TouchableOpacity>
<TouchableOpacity onPress={this.onPressConnect} style={styles.button}>
<Text style={styles.text}>CONNECT</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
button: {
marginVertical: 15,
width: '50%',
backgroundColor: 'purple',
padding: 7.5,
borderRadius: 25,
},
text: {
fontSize: 18,
color: 'white',
textAlign: 'center'
},
});