-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
107 lines (95 loc) · 3.46 KB
/
App.tsx
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import * as React from 'react';
import {Alert, Button, SafeAreaView, StyleSheet} from 'react-native';
import {
Affise
} from 'affise-attribution-lib';
import {AffiseWidget} from "./affise/AffiseWidget";
import {AffiseApiWidget} from "./affise/AffiseApiWidget";
import {useEffect} from "react";
import {AffiseStore} from "./affise/store/AffiseStore";
import {AffiseIndexContainer} from "./affise/components/AffiseIndexContainer";
import {AffiseButtonGroup} from "./affise/components/AffiseButtonGroup";
export default function App() {
const [deeplink, setDeeplink] = React.useState("");
const [tabIndex, setTabIndex] = React.useState(0);
useEffect(() => {
// Initialize https://github.com/affise/sdk-react#initialize
Affise
.settings({
affiseAppId: '129', //Change to your app id
secretKey: '93a40b54-6f12-443f-a250-ebf67c5ee4d2', //Change to your secretId
})
.setProduction(false) //To enable debug methods set Production to false
.start(); // Start Affise SDK
// Deeplinks https://github.com/affise/sdk-react#deeplinks
Affise.registerDeeplinkCallback((value) => {
console.log(`Deeplink: ${value}`);
setDeeplink(`Deeplink: ${value}`);
const parameters = Object.entries(value.parameters).map(([k, v]) => `${k}=[${v.join(", ")}]`).join("; ");
Alert.alert("Deeplink", `${value.deeplink}\n\n` +
`scheme: "${value.scheme}"\n` +
`host: "${value.host}"\n` +
`path: "${value.path}"\n` +
`parameters: [${parameters}]`, [
{text: 'OK', onPress: () => {}},
]);
});
// Debug: network request/response
Affise.debug.network((_request, response) =>
{
// console.log(`Affise: ${request}`);
console.log(`Affise: ${response}`);
});
// SDK to SDK integrations https://github.com/affise/sdk-react#sdk-to-sdk-integrations
// new AffiseAdRevenue(AffiseAdSource.ADMOB)
// .setRevenue(2.5, "USD")
// .setNetwork("network")
// .setUnit("unit")
// .setPlacement("placement")
// .send();
}, []);
return (
<SafeAreaView style={styles.container}>
<AffiseButtonGroup style={styles.buttonGroup}>
<Button
title='API'
onPress={() => setTabIndex(0) }
/>
<Button
title='Events'
onPress={() => setTabIndex(1) }
/>
<Button
title='Store'
onPress={() => setTabIndex(2) }
/>
</AffiseButtonGroup>
<AffiseIndexContainer index={tabIndex} style={styles.flexWidth}>
<AffiseApiWidget value={deeplink}/>
<AffiseWidget/>
<AffiseStore/>
</AffiseIndexContainer>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
buttonGroup: {
justifyContent: "space-between",
flexDirection: "row",
alignContent: "stretch",
width: '100%',
paddingTop: 8,
paddingBottom: 8,
paddingLeft: 4,
paddingRight: 4
},
flexWidth: {
width: '100%',
flex: 1
}
});