Skip to content

Commit 132ca5e

Browse files
committed
fixes and add origin
1 parent a2022ab commit 132ca5e

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

templates/react-native/README.md.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
To install
2626

2727
```bash
28-
npm install react-native-appwrite react-native-fs react-native-url-polyfill --save
28+
npx expo install react-native-appwrite react-native-url-polyfill
2929
```
3030

3131
{% if sdk.gettingStarted %}

templates/react-native/package.json.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
"typescript": "4.7.2"
3434
},
3535
"dependencies": {
36-
"cross-fetch": "3.1.5",
37-
"isomorphic-form-data": "2.0.0",
38-
"react-native": "^0.73.5",
39-
"react-native-fs": "^2.20.0",
40-
"react-native-url-polyfill": "^2.0.0"
36+
"expo-file-system": "16.0.8",
37+
"expo-device": "5.9.3"
38+
},
39+
"peerDependencies": {
40+
"expo": "*"
4141
}
4242
}

templates/react-native/rollup.config.js.twig

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,5 @@ export default {
1717
file: pkg.module,
1818
sourcemap: true,
1919
},
20-
{
21-
format: "iife",
22-
file: pkg.jsdelivr,
23-
name: "Appwrite",
24-
extend: true,
25-
globals: {
26-
"cross-fetch": "window",
27-
"FormData": "FormData",
28-
},
29-
},
3020
],
3121
};

templates/react-native/src/client.ts.twig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import 'isomorphic-form-data';
2-
import { fetch } from 'cross-fetch';
31
import { Models } from './models';
42
import { Service } from './service';
3+
import * as Device from 'expo-device'
54

65
type Payload = {
76
[key: string]: any;
@@ -210,7 +209,11 @@ class Client {
210209
}
211210

212211
this.realtime.url = url;
213-
this.realtime.socket = new WebSocket(url);
212+
this.realtime.socket = new WebSocket(url, undefined, {
213+
headers: {
214+
Origin: `{{ spec.title | caseLower }}-${Device.osName}://${this.config.platform}`
215+
}
216+
});
214217
this.realtime.socket.addEventListener('message', this.realtime.onMessage);
215218
this.realtime.socket.addEventListener('open', _event => {
216219
this.realtime.reconnectAttempts = 0;
@@ -327,6 +330,7 @@ class Client {
327330

328331

329332
headers = Object.assign({}, this.headers, headers);
333+
headers.Origin = `{{ spec.title | caseLower }}-${Device.osName}://${this.config.platform}`
330334

331335
let options: RequestInit = {
332336
method,

0 commit comments

Comments
 (0)