@originallyus/feedback-rn-sdk 1.0.2 → 1.0.4
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/README.md +94 -5
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -5,18 +5,18 @@ A cross-platform Feedback component for React Native.
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
Add package:
|
|
8
|
-
|
|
9
8
|
```sh
|
|
10
9
|
npm install @originallyus/feedback-rn-sdk
|
|
11
10
|
```
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
## Install Peer Dependencies
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
These packages are specified as peerDependencies and need to be installed separatedly.
|
|
15
|
+
```
|
|
16
|
+
yarn add axios crypto-js react-native-encrypted-storage react-native-device-info react-native-rate react-native-root-sibling
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## Install Custom Fonts
|
|
20
20
|
|
|
21
21
|
Package requires custom fonts found in `fonts` folder:
|
|
22
22
|
|
|
@@ -34,3 +34,92 @@ OpenSans-SemiBold.ttf
|
|
|
34
34
|
Please follow this guide to install fonts: [`Install Fonts to RN App`](https://medium.com/@prathiba2796/how-to-add-and-use-custom-fonts-in-react-native-369d5bba9203)
|
|
35
35
|
|
|
36
36
|
Please do not change the filenames as Android are using those to identify fonts. These filenames follows actual PostScript Name of the fonts.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
Please initalize the SDK once in App.js. The mounting point of the SDK should be placed directly in your App.js for it to stay on top of all other views.
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import AIAFeedback from '@originallyus/feedback-rn-sdk';
|
|
45
|
+
|
|
46
|
+
const App = (props) => {
|
|
47
|
+
// This initialization should done once inside App.js
|
|
48
|
+
const feedbackRef = useRef();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// in your render function
|
|
52
|
+
return (
|
|
53
|
+
// Make sure the app is full screen and vertical align center
|
|
54
|
+
<View style={{ flex: 1, justifyContent: 'center' }}>
|
|
55
|
+
<YourOtherContainerView></YourOtherContainerView>
|
|
56
|
+
|
|
57
|
+
{/* Please insert this mount point directly in your App.js,
|
|
58
|
+
preferably at the bottom of your root view tree for it to stay on top of all other views */}
|
|
59
|
+
<AIAFeedback ref={feedbackRef} />
|
|
60
|
+
</View>
|
|
61
|
+
);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
All other functions to be invoked on feedbackRef.current can be done anywhere in your application code (can also be inside App.js)
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
import AIAFeedback from '@originallyus/feedback-rn-sdk';
|
|
68
|
+
|
|
69
|
+
const OtherComponent = (props) => {
|
|
70
|
+
// This is a singleton. The initialization should have already been done inside App.js
|
|
71
|
+
const feedbackRef = useRef();
|
|
72
|
+
|
|
73
|
+
const setupFeedbackSDK = () => {
|
|
74
|
+
// Please contact us to obtain an App Secret specific to your Bundle ID/Package ID
|
|
75
|
+
feedbackRef.current.setAppSecret('QcJasjiu2olMBxHyFohKJ');
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const setLanguage = (language) => {
|
|
79
|
+
// Use international language codes: "en", "zh", "zh_tw", "ms", "ta", "id", "th", "tl", "vi"
|
|
80
|
+
// Note: our backend must be loaded with the translation content before a language can be used. Invalid languages will automatically fallback to English
|
|
81
|
+
feedbackRef.current.setLanguage(language);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const setAppUserId = () => {
|
|
85
|
+
// This is an optional User ID provided by the host app.
|
|
86
|
+
feedbackRef.current.setAppUserId('1234');
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const setMetadata = () => {
|
|
90
|
+
// This is an optional metadata provided by the host app. Supports string format only.
|
|
91
|
+
feedbackRef.current.setMetadata('policy_1234567890');
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const testRatingForm = (eventTag) => {
|
|
95
|
+
// This will always show the Feedback form for testing/debugging purpose
|
|
96
|
+
// You may troubleshoot this in "Request (Testing)" section in CMS
|
|
97
|
+
feedbackRef.current.setFormSlug('native_rating_form');
|
|
98
|
+
feedbackRef.current.testRatingForm(eventTag);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const showRatingForm = (eventTag) => {
|
|
102
|
+
// This may not always show/trigger the form, depending on the Response Frequency & Prompt Frequency configuration on backend
|
|
103
|
+
// You may troubleshoot this in "Request" section in CMS
|
|
104
|
+
feedbackRef.current.showRatingForm(eventTag);
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## Callback Function (optional)
|
|
111
|
+
|
|
112
|
+
An optional callback function can be provided as parameter to capture the outcome of the SDK.
|
|
113
|
+
|
|
114
|
+
- **formDidShow = false** is triggered when there is no form to be shown, this callback function will be triggered almost immediately.
|
|
115
|
+
- **formDidShow = true** is triggered when has been shown and user has finished interacting with it or dismiss/cancel it
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
feedbackRef.current.testRatingForm(eventTag, (formDidShow) => {
|
|
119
|
+
console.log("formDidShow", formDidShow);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
feedbackRef.current.showRatingForm(eventTag, (formDidShow) => {
|
|
123
|
+
console.log("formDidShow", formDidShow);
|
|
124
|
+
});
|
|
125
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@originallyus/feedback-rn-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A cross-platform Feedback component for React Native.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"react-native": "lib/commonjs/index",
|
|
@@ -58,10 +58,6 @@
|
|
|
58
58
|
"resolutions": {
|
|
59
59
|
"@types/react": "17.0.21"
|
|
60
60
|
},
|
|
61
|
-
"peerDependencies": {
|
|
62
|
-
"react": "*",
|
|
63
|
-
"react-native": "*"
|
|
64
|
-
},
|
|
65
61
|
"workspaces": [
|
|
66
62
|
"example"
|
|
67
63
|
],
|
|
@@ -136,13 +132,17 @@
|
|
|
136
132
|
]
|
|
137
133
|
]
|
|
138
134
|
},
|
|
135
|
+
"peerDependencies": {
|
|
136
|
+
"axios": "*",
|
|
137
|
+
"crypto-js": "*",
|
|
138
|
+
"react": "*",
|
|
139
|
+
"react-native": "*",
|
|
140
|
+
"react-native-device-info": "*",
|
|
141
|
+
"react-native-encrypted-storage": "*",
|
|
142
|
+
"react-native-rate": "*",
|
|
143
|
+
"react-native-root-siblings": "*"
|
|
144
|
+
},
|
|
139
145
|
"dependencies": {
|
|
140
|
-
"
|
|
141
|
-
"crypto-js": "^4.2.0",
|
|
142
|
-
"react-native-android-keyboard-adjust-originallyus": "^1.0.2",
|
|
143
|
-
"react-native-device-info": "^10.12.0",
|
|
144
|
-
"react-native-encrypted-storage": "^4.0.3",
|
|
145
|
-
"react-native-rate": "^1.2.12",
|
|
146
|
-
"react-native-screens": "^3.29.0"
|
|
146
|
+
"react-native-android-keyboard-adjust-originallyus": "*"
|
|
147
147
|
}
|
|
148
148
|
}
|