-
Notifications
You must be signed in to change notification settings - Fork 84
/
index.js
36 lines (29 loc) · 1.09 KB
/
index.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
/**
* @file Logout Button.
* @author Vadim Savin
*/
import React from 'react';
import { Pressable, Text, Alert } from 'react-native';
import Purchases from 'react-native-purchases';
import styles from './styles';
const LogoutButton = ({ onLogout }) => {
const logout = async () => {
/*
The current user ID is no longer valid for your instance of *Purchases* since the user is logging out, and is no longer authorized to access purchaserInfo for that user ID.
`reset` clears the cache and regenerates a new anonymous user ID.
Note: Each time you call `reset`, a new installation will be logged in the RevenueCat dashboard as that metric tracks unique user ID's that are in-use. Since this method generates a new anonymous ID, it counts as a new user ID in-use.
*/
try {
await Purchases.logOut();
} catch (e) {
Alert.alert('Error resetting purchases', e.message);
}
await onLogout();
};
return (
<Pressable onPress={logout} style={styles.button}>
<Text style={styles.text}>Logout</Text>
</Pressable>
);
};
export default LogoutButton;