Skip to content

Commit cc5d722

Browse files
authored
Update README.md
1 parent 9305543 commit cc5d722

File tree

1 file changed

+90
-4
lines changed

1 file changed

+90
-4
lines changed

README.md

Lines changed: 90 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# NativeScript-HTTPS
22
### The definitive way to hit HTTP based APIs in Nativescript.
33
Easily integrate the most reliable native networking libraries with the latest and greatest HTTPS security features.
4-
#### A drop-in replacement for the default [http module](https://docs.nativescript.org/cookbook/http#get-response-status-code).
4+
#### A drop-in replacement for the [default http module](https://docs.nativescript.org/cookbook/http#get-response-status-code).
55

66
## Features
7-
- Modern TLS security features (SNI, ALPN)
7+
- Modern TLS security features
88
- Shared connection pooling reduces request latency
99
- Silently recovers from common connection problems
1010
- Everything runs on a native background thread
@@ -17,6 +17,92 @@ iOS | Android
1717
[AFNetworking](https://github.com/AFNetworking/AFNetworking) | [okhttp3](https://github.com/square/okhttp)
1818

1919
## FAQ
20-
> Do I have to use SSL pinning and all this security mumbo jumbo?
21-
**No.** This plugin
20+
> What the flip is SSL pinning and all this security mumbo jumbo?
21+
22+
[How to make your apps more secure with SSL pinning](https://infinum.co/the-capsized-eight/how-to-make-your-ios-apps-more-secure-with-ssl-pinning).
23+
24+
> Do I have to use SSL pinning?
25+
26+
**No.** This plugin works out of the box without any security configurations needed. Either way you'll still benefit from all the features listed above.
27+
28+
## Demo
29+
```shell
30+
git clone https://github.com/gethuman/nativescript-https
31+
cd nativescript-https
32+
npm run setup
33+
npm run demo.ios
34+
npm run demo.android
35+
```
36+
37+
## Installation
38+
#### Add `tns-platform-declarations` for Android and iOS to your `reference.d.ts`!
39+
```typescript
40+
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
41+
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
42+
```
43+
We also recommend adding `"skipLibCheck": true,` to your `tsconfig.json`.
44+
More information on that can be found [here](https://github.com/NativeScript/NativeScript/tree/master/tns-platform-declarations).
45+
46+
```bash
47+
tns plugin add nativescript-https
48+
```
49+
50+
## Examples
51+
### Hitting an API using `GET` method
52+
```typescript
53+
import * as Https from 'nativescript-https'
54+
Https.request({
55+
url: 'https://wegossipapp.com/api/newuser',
56+
method: 'GET',
57+
headers: {
58+
'Authorization': 'Basic ZWx1c3VhcmlvOnlsYWNsYXZl',
59+
'x-uuid': 'aHR0cHdhdGNoOmY',
60+
'x-version': '4.2.0',
61+
'x-env': 'DEVELOPMENT',
62+
},
63+
}).then(function(response) {
64+
console.log('Https.request response', response)
65+
}).catch(function(error) {
66+
console.error('Https.request error', error)
67+
})
68+
```
69+
### Hitting an API using `POST` method with body
70+
```typescript
71+
import * as Https from 'nativescript-https'
72+
Https.request({
73+
url: 'https://wegossipapp.com/api/newuser',
74+
method: 'POST',
75+
headers: {
76+
'Authorization': 'Basic ZWx1c3VhcmlvOnlsYWNsYXZl',
77+
'x-uuid': 'aHR0cHdhdGNoOmY',
78+
'x-version': '4.2.0',
79+
'x-env': 'DEVELOPMENT',
80+
},
81+
content: JSON.stringify({
82+
'username': 'roblav96',
83+
'password': 'password',
84+
})
85+
}).then(function(response) {
86+
console.log('Https.request response', response)
87+
}).catch(function(error) {
88+
console.error('Https.request error', error)
89+
})
90+
```
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
107+
22108

0 commit comments

Comments
 (0)