@trycourier/courier-react-native 5.4.3 → 5.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +2 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/courierreactnative/CourierClientModule.kt +298 -303
- package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +194 -165
- package/android/src/main/java/com/courierreactnative/Utils.kt +1 -1
- package/courier-react-native.podspec +1 -1
- package/ios/CourierReactNativeDelegate.m +12 -8
- package/ios/CourierReactNativeEventEmitter.swift +1 -1
- package/ios/CourierReactNativeModule.m +3 -5
- package/ios/CourierSharedModule.swift +88 -112
- package/lib/commonjs/index.js +75 -93
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierInboxListener.js +1 -0
- package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
- package/lib/commonjs/models/InboxAction.js +22 -0
- package/lib/commonjs/models/InboxAction.js.map +1 -1
- package/lib/commonjs/models/InboxMessage.js +64 -0
- package/lib/commonjs/models/InboxMessage.js.map +1 -1
- package/lib/commonjs/models/InboxMessageEvent.js +2 -0
- package/lib/commonjs/models/InboxMessageEvent.js.map +1 -0
- package/lib/commonjs/views/CourierInboxView.js +6 -4
- package/lib/commonjs/views/CourierInboxView.js.map +1 -1
- package/lib/example/src/App.js +11 -0
- package/lib/example/src/Emitter.js +11 -0
- package/lib/example/src/Env.js +6 -0
- package/lib/example/src/Home.js +67 -0
- package/lib/example/src/Poke.js +75 -0
- package/lib/example/src/Tabs.js +36 -0
- package/lib/example/src/Utils.js +71 -0
- package/lib/example/src/pages/Auth.js +224 -0
- package/lib/example/src/pages/Inbox.js +38 -0
- package/lib/example/src/pages/Preferences.js +13 -0
- package/lib/example/src/pages/PreferencesStack.js +11 -0
- package/lib/example/src/pages/Push.js +93 -0
- package/lib/example/src/pages/Styles.js +26 -0
- package/lib/example/src/pages/Tests.js +1068 -0
- package/lib/example/src/pages/inbox/InboxCustom.js +141 -0
- package/lib/example/src/pages/inbox/InboxDefault.js +22 -0
- package/lib/example/src/pages/inbox/InboxStyled.js +220 -0
- package/lib/example/src/pages/preferences/PreferencesCustom.js +91 -0
- package/lib/example/src/pages/preferences/PreferencesDefault.js +17 -0
- package/lib/example/src/pages/preferences/PreferencesDetail.js +127 -0
- package/lib/example/src/pages/preferences/PreferencesStyled.js +110 -0
- package/lib/module/index.js +67 -90
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js +1 -0
- package/lib/module/models/CourierInboxListener.js.map +1 -1
- package/lib/module/models/InboxAction.js +16 -1
- package/lib/module/models/InboxAction.js.map +1 -1
- package/lib/module/models/InboxMessage.js +61 -1
- package/lib/module/models/InboxMessage.js.map +1 -1
- package/lib/module/models/InboxMessageEvent.js +2 -0
- package/lib/module/models/InboxMessageEvent.js.map +1 -0
- package/lib/module/views/CourierInboxView.js +6 -4
- package/lib/module/views/CourierInboxView.js.map +1 -1
- package/lib/package.json +171 -0
- package/lib/src/Broadcaster.js +24 -0
- package/lib/src/Modules.js +26 -0
- package/lib/src/client/BrandClient.js +17 -0
- package/lib/src/client/ClientModule.js +14 -0
- package/lib/src/client/CourierClient.js +31 -0
- package/lib/src/client/InboxClient.js +99 -0
- package/lib/src/client/PreferenceClient.js +63 -0
- package/lib/src/client/TokenClient.js +27 -0
- package/lib/src/client/TrackingClient.js +17 -0
- package/lib/src/index.js +567 -0
- package/lib/src/models/Android_CourierSheet.js +1 -0
- package/lib/src/models/CourierAuthenticationListener.js +14 -0
- package/lib/src/models/CourierBrand.js +1 -0
- package/lib/src/models/CourierButton.js +1 -0
- package/lib/src/models/CourierDevice.js +1 -0
- package/lib/src/models/CourierFont.js +1 -0
- package/lib/src/models/CourierInboxListener.js +20 -0
- package/lib/src/models/CourierInboxMessages.js +1 -0
- package/lib/src/models/CourierInboxTheme.js +1 -0
- package/lib/src/models/CourierInfoViewStyle.js +1 -0
- package/lib/src/models/CourierPaging.js +1 -0
- package/lib/src/models/CourierPreferencesTheme.js +1 -0
- package/lib/src/models/CourierPushListener.js +14 -0
- package/lib/src/models/CourierPushProvider.js +8 -0
- package/lib/src/models/CourierTrackingEvent.js +8 -0
- package/lib/src/models/CourierUserPreferences.js +51 -0
- package/lib/src/models/InboxAction.js +1 -0
- package/lib/src/models/InboxMessage.js +1 -0
- package/lib/src/models/InboxMessageFeed.js +1 -0
- package/lib/src/models/InboxMessageSet.js +1 -0
- package/lib/src/models/iOS_CourierCell.js +1 -0
- package/lib/src/models/iOS_CourierSheet.js +1 -0
- package/lib/src/utils.js +27 -0
- package/lib/src/views/CourierInboxView.js +75 -0
- package/lib/src/views/CourierPreferencesView.js +33 -0
- package/lib/typescript/src/index.d.ts +16 -20
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierInboxListener.d.ts +4 -7
- package/lib/typescript/src/models/CourierInboxListener.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxAction.d.ts +8 -4
- package/lib/typescript/src/models/InboxAction.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessage.d.ts +28 -14
- package/lib/typescript/src/models/InboxMessage.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessageEvent.d.ts +2 -0
- package/lib/typescript/src/models/InboxMessageEvent.d.ts.map +1 -0
- package/lib/typescript/src/models/InboxMessageFeed.d.ts +1 -1
- package/lib/typescript/src/models/InboxMessageFeed.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/index.tsx +61 -99
- package/src/models/CourierInboxListener.tsx +10 -13
- package/src/models/InboxAction.tsx +28 -4
- package/src/models/InboxMessage.tsx +102 -14
- package/src/models/InboxMessageEvent.tsx +1 -0
- package/src/models/InboxMessageFeed.tsx +1 -1
- package/src/views/CourierInboxView.tsx +4 -4
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/xcuserdata/mike.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/CourierReactNative.xcodeproj/xcuserdata/mike.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import Courier from "@trycourier/courier-react-native";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { ActivityIndicator, Button, Modal, Platform, StyleSheet, Text, TextInput, TouchableOpacity, View } from "react-native";
|
|
4
|
+
import Env from "../Env";
|
|
5
|
+
import { ExampleServer } from "../Utils";
|
|
6
|
+
import { usePoke } from '../Poke';
|
|
7
|
+
const Auth = () => {
|
|
8
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
9
|
+
const [userId, setUserId] = useState();
|
|
10
|
+
const [tenantId, setTenantId] = useState();
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const initAuth = async () => {
|
|
13
|
+
const authListener = await Courier.shared.addAuthenticationListener({
|
|
14
|
+
onUserChanged: async (userId) => {
|
|
15
|
+
setUserId(userId);
|
|
16
|
+
setTenantId(await Courier.shared.getTenantId());
|
|
17
|
+
console.log(`User changed: ${userId}`);
|
|
18
|
+
console.log(`Tenant changed: ${await Courier.shared.getTenantId()}`);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const userId = await Courier.shared.getUserId();
|
|
22
|
+
const tenantId = await Courier.shared.getTenantId();
|
|
23
|
+
console.log(`Initial user: ${userId}`);
|
|
24
|
+
console.log(`Initial tenant: ${tenantId}`);
|
|
25
|
+
refreshJWT(userId, tenantId);
|
|
26
|
+
return authListener;
|
|
27
|
+
};
|
|
28
|
+
let listener;
|
|
29
|
+
initAuth().then(result => {
|
|
30
|
+
listener = result;
|
|
31
|
+
});
|
|
32
|
+
return () => {
|
|
33
|
+
if (listener) {
|
|
34
|
+
listener.remove();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}, []);
|
|
38
|
+
async function refreshJWT(userId, tenantId) {
|
|
39
|
+
console.log('Refreshing JWT');
|
|
40
|
+
if (!userId) {
|
|
41
|
+
console.log(`No user found`);
|
|
42
|
+
setIsLoading(false);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
setIsLoading(true);
|
|
46
|
+
try {
|
|
47
|
+
console.log(`User ID: ${userId}`);
|
|
48
|
+
await Courier.shared.signOut();
|
|
49
|
+
const token = await ExampleServer.generateJwt({
|
|
50
|
+
authKey: Env.authKey,
|
|
51
|
+
userId: userId,
|
|
52
|
+
});
|
|
53
|
+
console.log(`New token: ${token}`);
|
|
54
|
+
await Courier.shared.signIn({
|
|
55
|
+
accessToken: token,
|
|
56
|
+
userId: userId,
|
|
57
|
+
tenantId: tenantId,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
console.error(e);
|
|
62
|
+
}
|
|
63
|
+
setIsLoading(false);
|
|
64
|
+
}
|
|
65
|
+
async function signIn(userId, tenantId) {
|
|
66
|
+
console.log('Signing User In');
|
|
67
|
+
console.log(`User ID: ${userId}`);
|
|
68
|
+
console.log(`Tenant ID: ${tenantId}`);
|
|
69
|
+
setIsLoading(true);
|
|
70
|
+
try {
|
|
71
|
+
const token = await ExampleServer.generateJwt({
|
|
72
|
+
authKey: Env.authKey,
|
|
73
|
+
userId: userId,
|
|
74
|
+
});
|
|
75
|
+
console.log(`New token: ${token}`);
|
|
76
|
+
await Courier.shared.signIn({
|
|
77
|
+
accessToken: token,
|
|
78
|
+
userId: userId,
|
|
79
|
+
tenantId: tenantId.length ? tenantId : undefined
|
|
80
|
+
});
|
|
81
|
+
setUserId(await Courier.shared.getUserId());
|
|
82
|
+
setTenantId(await Courier.shared.getTenantId());
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
console.error(e);
|
|
86
|
+
}
|
|
87
|
+
setIsLoading(false);
|
|
88
|
+
}
|
|
89
|
+
async function signOut() {
|
|
90
|
+
await Courier.shared.signOut();
|
|
91
|
+
setUserId(await Courier.shared.getUserId());
|
|
92
|
+
setTenantId(await Courier.shared.getTenantId());
|
|
93
|
+
}
|
|
94
|
+
const styles = StyleSheet.create({
|
|
95
|
+
container: {
|
|
96
|
+
flex: 1,
|
|
97
|
+
justifyContent: 'center',
|
|
98
|
+
alignItems: 'center',
|
|
99
|
+
},
|
|
100
|
+
text: {
|
|
101
|
+
marginBottom: 10,
|
|
102
|
+
fontFamily: Platform.select({
|
|
103
|
+
ios: 'Courier',
|
|
104
|
+
android: 'monospace',
|
|
105
|
+
default: 'monospace',
|
|
106
|
+
}),
|
|
107
|
+
fontSize: 16,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
const AuthButton = (props) => {
|
|
111
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
112
|
+
const [userId, setUserId] = useState('');
|
|
113
|
+
const [tenantId, setTenantId] = useState('');
|
|
114
|
+
const inputRef = useRef(null);
|
|
115
|
+
const styles = StyleSheet.create({
|
|
116
|
+
button: {
|
|
117
|
+
backgroundColor: 'lightgray',
|
|
118
|
+
padding: 10,
|
|
119
|
+
borderRadius: 5,
|
|
120
|
+
},
|
|
121
|
+
buttonText: {
|
|
122
|
+
fontSize: 16,
|
|
123
|
+
fontFamily: Platform.select({
|
|
124
|
+
ios: 'Courier',
|
|
125
|
+
android: 'monospace',
|
|
126
|
+
default: 'monospace',
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
modalContainer: {
|
|
130
|
+
flex: 1,
|
|
131
|
+
justifyContent: 'center',
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
134
|
+
},
|
|
135
|
+
modalContent: {
|
|
136
|
+
backgroundColor: 'white',
|
|
137
|
+
padding: 20,
|
|
138
|
+
borderRadius: 5,
|
|
139
|
+
elevation: 5,
|
|
140
|
+
minWidth: 300,
|
|
141
|
+
},
|
|
142
|
+
input: {
|
|
143
|
+
borderWidth: 1,
|
|
144
|
+
borderColor: 'gray',
|
|
145
|
+
borderRadius: 5,
|
|
146
|
+
padding: 10,
|
|
147
|
+
marginBottom: 10,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
if (modalVisible) {
|
|
152
|
+
inputRef.current.focus();
|
|
153
|
+
}
|
|
154
|
+
}, [modalVisible]);
|
|
155
|
+
const handleButtonPress = async () => {
|
|
156
|
+
if (await Courier.shared.getUserId()) {
|
|
157
|
+
await signOut();
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
setModalVisible(true);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const handleModalClose = () => {
|
|
164
|
+
setModalVisible(false);
|
|
165
|
+
};
|
|
166
|
+
const handleUserIdInputChange = (text) => {
|
|
167
|
+
setUserId(text);
|
|
168
|
+
};
|
|
169
|
+
const handleTenantIdInputChange = (text) => {
|
|
170
|
+
setTenantId(text);
|
|
171
|
+
};
|
|
172
|
+
const handleSaveButtonPress = () => {
|
|
173
|
+
signIn(userId, tenantId);
|
|
174
|
+
setModalVisible(false);
|
|
175
|
+
};
|
|
176
|
+
return (React.createElement(React.Fragment, null,
|
|
177
|
+
React.createElement(Modal, { visible: modalVisible, animationType: "slide", transparent: true },
|
|
178
|
+
React.createElement(View, { style: styles.modalContainer },
|
|
179
|
+
React.createElement(View, { style: styles.modalContent },
|
|
180
|
+
React.createElement(Text, null, "Set Courier User Id:"),
|
|
181
|
+
React.createElement(TextInput, { ref: inputRef, style: styles.input, value: userId, autoCapitalize: "none", autoCorrect: false, onChangeText: handleUserIdInputChange }),
|
|
182
|
+
React.createElement(Text, null, "Set Tenant Id:"),
|
|
183
|
+
React.createElement(TextInput, { style: styles.input, value: tenantId, autoCapitalize: "none", autoCorrect: false, onChangeText: handleTenantIdInputChange }),
|
|
184
|
+
React.createElement(Button, { title: "Sign In", onPress: handleSaveButtonPress }),
|
|
185
|
+
React.createElement(Button, { title: "Cancel", onPress: handleModalClose })))),
|
|
186
|
+
React.createElement(TouchableOpacity, { style: styles.button, onPress: handleButtonPress },
|
|
187
|
+
React.createElement(Text, { style: styles.buttonText }, props.buttonText))));
|
|
188
|
+
};
|
|
189
|
+
const ToggleTouchesButton = () => {
|
|
190
|
+
const styles = StyleSheet.create({
|
|
191
|
+
button: {
|
|
192
|
+
backgroundColor: 'lightgray',
|
|
193
|
+
padding: 10,
|
|
194
|
+
borderRadius: 5,
|
|
195
|
+
marginTop: 10, // Add some space between buttons
|
|
196
|
+
},
|
|
197
|
+
buttonText: {
|
|
198
|
+
fontSize: 16,
|
|
199
|
+
fontFamily: Platform.select({
|
|
200
|
+
ios: 'Courier',
|
|
201
|
+
android: 'monospace',
|
|
202
|
+
default: 'monospace',
|
|
203
|
+
}),
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
const [enabled, setEnabledState] = useState(false);
|
|
207
|
+
const { setEnabled } = usePoke();
|
|
208
|
+
const handleToggle = () => {
|
|
209
|
+
const newEnabled = !enabled;
|
|
210
|
+
setEnabledState(newEnabled);
|
|
211
|
+
setEnabled(newEnabled);
|
|
212
|
+
};
|
|
213
|
+
return (React.createElement(TouchableOpacity, { style: styles.button, onPress: handleToggle },
|
|
214
|
+
React.createElement(Text, { style: styles.buttonText }, enabled ? 'Hide Touches' : 'Show Touches')));
|
|
215
|
+
};
|
|
216
|
+
return (React.createElement(View, { style: styles.container },
|
|
217
|
+
isLoading && (React.createElement(ActivityIndicator, { size: "small" })),
|
|
218
|
+
!isLoading && (React.createElement(React.Fragment, null,
|
|
219
|
+
userId && React.createElement(Text, { style: styles.text }, userId),
|
|
220
|
+
tenantId && React.createElement(Text, { style: styles.text }, tenantId),
|
|
221
|
+
React.createElement(AuthButton, { buttonText: userId ? 'Sign Out' : 'Sign In' }),
|
|
222
|
+
React.createElement(ToggleTouchesButton, null)))));
|
|
223
|
+
};
|
|
224
|
+
export default Auth;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import InboxDefault from './inbox/InboxDefault';
|
|
4
|
+
import InboxStyled from './inbox/InboxStyled';
|
|
5
|
+
import InboxCustom from './inbox/InboxCustom';
|
|
6
|
+
import { TabControl } from '../Tabs';
|
|
7
|
+
const tabs = [
|
|
8
|
+
{ title: 'Default', key: 'Default' },
|
|
9
|
+
{ title: 'Styled', key: 'Styled' },
|
|
10
|
+
{ title: 'Custom', key: 'Custom' },
|
|
11
|
+
];
|
|
12
|
+
const Inbox = () => {
|
|
13
|
+
const [selectedTab, setSelectedTab] = useState('Default');
|
|
14
|
+
const renderContent = () => {
|
|
15
|
+
switch (selectedTab) {
|
|
16
|
+
case 'Default':
|
|
17
|
+
return React.createElement(InboxDefault, null);
|
|
18
|
+
case 'Styled':
|
|
19
|
+
return React.createElement(InboxStyled, null);
|
|
20
|
+
case 'Custom':
|
|
21
|
+
return React.createElement(InboxCustom, null);
|
|
22
|
+
default:
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return (React.createElement(View, { style: styles.container },
|
|
27
|
+
React.createElement(TabControl, { tabs: tabs, selectedTab: selectedTab, setSelectedTab: setSelectedTab }),
|
|
28
|
+
React.createElement(View, { style: styles.content }, renderContent())));
|
|
29
|
+
};
|
|
30
|
+
const styles = StyleSheet.create({
|
|
31
|
+
container: {
|
|
32
|
+
flex: 1,
|
|
33
|
+
},
|
|
34
|
+
content: {
|
|
35
|
+
flex: 1,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export default Inbox;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
|
|
3
|
+
import PreferencesCustom from './preferences/PreferencesCustom';
|
|
4
|
+
import PreferencesDefault from './preferences/PreferencesDefault';
|
|
5
|
+
import PreferencesStyled from './preferences/PreferencesStyled';
|
|
6
|
+
const Tab = createMaterialTopTabNavigator();
|
|
7
|
+
const PreferencesTab = () => {
|
|
8
|
+
return (React.createElement(Tab.Navigator, null,
|
|
9
|
+
React.createElement(Tab.Screen, { name: "Default", component: PreferencesDefault }),
|
|
10
|
+
React.createElement(Tab.Screen, { name: "Styled", component: PreferencesStyled }),
|
|
11
|
+
React.createElement(Tab.Screen, { name: "Custom", component: PreferencesCustom })));
|
|
12
|
+
};
|
|
13
|
+
export default PreferencesTab;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
3
|
+
import Preferences from './Preferences';
|
|
4
|
+
import PreferencesDetail from './preferences/PreferencesDetail';
|
|
5
|
+
const Stack = createStackNavigator();
|
|
6
|
+
const PreferencesStack = () => {
|
|
7
|
+
return (React.createElement(Stack.Navigator, null,
|
|
8
|
+
React.createElement(Stack.Screen, { name: "PreferencesTab", component: Preferences }),
|
|
9
|
+
React.createElement(Stack.Screen, { name: "PreferencesDetail", component: PreferencesDetail })));
|
|
10
|
+
};
|
|
11
|
+
export default PreferencesStack;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import Courier, { CourierPushProvider } from '@trycourier/courier-react-native';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { View, Text, StyleSheet, TouchableOpacity, Clipboard, ActivityIndicator, Platform } from 'react-native';
|
|
4
|
+
const Push = () => {
|
|
5
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
6
|
+
const [tokens, setTokens] = useState(new Map());
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
setExampleToken();
|
|
9
|
+
}, []);
|
|
10
|
+
const refreshTokens = async () => {
|
|
11
|
+
const tokensMap = await Courier.shared.getAllTokens();
|
|
12
|
+
setTokens(tokensMap);
|
|
13
|
+
};
|
|
14
|
+
const setExampleToken = async () => {
|
|
15
|
+
setIsLoading(true);
|
|
16
|
+
const requestStatus = await Courier.requestNotificationPermission();
|
|
17
|
+
console.log('Request Notification Status: ' + requestStatus);
|
|
18
|
+
console.log('Get Notification Status: ' + await Courier.getNotificationPermissionStatus());
|
|
19
|
+
// Example of setting an expo token
|
|
20
|
+
await Courier.shared.setTokenForProvider({
|
|
21
|
+
provider: CourierPushProvider.EXPO,
|
|
22
|
+
token: 'example_expo_token'
|
|
23
|
+
});
|
|
24
|
+
setIsLoading(false);
|
|
25
|
+
refreshTokens();
|
|
26
|
+
};
|
|
27
|
+
const styles = StyleSheet.create({
|
|
28
|
+
container: {
|
|
29
|
+
flex: 1,
|
|
30
|
+
gap: 20,
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
padding: 20,
|
|
34
|
+
},
|
|
35
|
+
button: {
|
|
36
|
+
backgroundColor: 'lightgray',
|
|
37
|
+
padding: 10,
|
|
38
|
+
borderRadius: 5,
|
|
39
|
+
},
|
|
40
|
+
buttonText: {
|
|
41
|
+
fontSize: 16,
|
|
42
|
+
fontFamily: Platform.select({
|
|
43
|
+
ios: 'Courier',
|
|
44
|
+
android: 'monospace',
|
|
45
|
+
default: 'monospace',
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
itemContainer: {
|
|
49
|
+
flexDirection: 'row',
|
|
50
|
+
justifyContent: 'space-between',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
paddingVertical: 8,
|
|
53
|
+
},
|
|
54
|
+
keyText: {
|
|
55
|
+
flex: 1,
|
|
56
|
+
textAlign: 'left',
|
|
57
|
+
fontFamily: Platform.select({
|
|
58
|
+
ios: 'Courier',
|
|
59
|
+
android: 'monospace',
|
|
60
|
+
default: 'monospace',
|
|
61
|
+
}),
|
|
62
|
+
fontWeight: 'bold',
|
|
63
|
+
fontSize: 16,
|
|
64
|
+
},
|
|
65
|
+
valueText: {
|
|
66
|
+
flex: 1,
|
|
67
|
+
textAlign: 'right',
|
|
68
|
+
fontFamily: Platform.select({
|
|
69
|
+
ios: 'Courier',
|
|
70
|
+
android: 'monospace',
|
|
71
|
+
default: 'monospace',
|
|
72
|
+
}),
|
|
73
|
+
fontSize: 16,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
const handleCopyToClipboard = (value) => {
|
|
77
|
+
Clipboard.setString(value);
|
|
78
|
+
};
|
|
79
|
+
const handleButtonPress = () => {
|
|
80
|
+
Courier.requestNotificationPermission();
|
|
81
|
+
};
|
|
82
|
+
return (React.createElement(View, { style: styles.container },
|
|
83
|
+
isLoading && (React.createElement(ActivityIndicator, { size: "small" })),
|
|
84
|
+
!isLoading && (React.createElement(React.Fragment, null,
|
|
85
|
+
Array.from(tokens).map(([key, value]) => (React.createElement(TouchableOpacity, { key: key, onPress: () => handleCopyToClipboard(value), style: styles.itemContainer },
|
|
86
|
+
React.createElement(Text, { style: styles.keyText }, key),
|
|
87
|
+
React.createElement(Text, { style: styles.valueText }, value)))),
|
|
88
|
+
React.createElement(TouchableOpacity, { style: styles.button, onPress: refreshTokens },
|
|
89
|
+
React.createElement(Text, { style: styles.buttonText }, "Refresh Tokens")),
|
|
90
|
+
React.createElement(TouchableOpacity, { style: styles.button, onPress: handleButtonPress },
|
|
91
|
+
React.createElement(Text, { style: styles.buttonText }, "Request Permissions"))))));
|
|
92
|
+
};
|
|
93
|
+
export default Push;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
export const Styles = (isDark) => {
|
|
3
|
+
return {
|
|
4
|
+
Fonts: {
|
|
5
|
+
heading: Platform.OS === 'ios' ? 'Avenir Medium' : 'fonts/poppins_regular.otf',
|
|
6
|
+
title: Platform.OS === 'ios' ? 'Avenir Medium' : 'fonts/poppins_regular.otf',
|
|
7
|
+
subtitle: Platform.OS === 'ios' ? 'Avenir Medium' : 'fonts/poppins_regular.otf'
|
|
8
|
+
},
|
|
9
|
+
Colors: {
|
|
10
|
+
heading: isDark ? '#9747FF' : '#9747FF',
|
|
11
|
+
title: isDark ? '#FFFFFF' : '#000000',
|
|
12
|
+
subtitle: isDark ? '#9A9A9A' : '#BEBEBE',
|
|
13
|
+
warning: isDark ? '#C32F27' : '#C32F27',
|
|
14
|
+
option: isDark ? '#1F1F1F' : '#F0F0F0',
|
|
15
|
+
action: isDark ? '#9747FF' : '#9747FF',
|
|
16
|
+
},
|
|
17
|
+
TextSizes: {
|
|
18
|
+
heading: 24,
|
|
19
|
+
title: 18,
|
|
20
|
+
subtitle: 16,
|
|
21
|
+
},
|
|
22
|
+
Corners: {
|
|
23
|
+
button: 100
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
};
|