Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ src/*.d.ts
seed-tests/seed-copy/**/*.*
seed-tests/seed-copy-new-git-repo/**/*.*
!demo/karma.conf.js
!demo/webpack.config.js
!demo/app/tests/*.js
demo/*.d.ts
!demo/references.d.ts
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ You can bypass this behavior by adding the following to your projects `Info.plis
```
> This plugin **does not** add `NSAllowsArbitraryLoads` to your projects `Info.plist` for you.

## `Android` troubleshooting
If you app crashes with a message that it's doing too much networkin on the main thread,
then pass the option `allowLargeResponse` with value `true` to the `request` function.

# Thanks
Who | Why
------------ | -------------
Expand Down
2 changes: 1 addition & 1 deletion demo/app/App_Resources/iOS/build.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// You can add custom settings here
// for example you can uncomment the following line to force distribution code signing
// CODE_SIGN_IDENTITY = iPhone Distribution
// CODE_SIGN_IDENTITY = iPhone Distribution
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
Binary file modified demo/app/assets/httpbin.org.cer
Binary file not shown.
24 changes: 19 additions & 5 deletions demo/app/main-page.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@

import * as Observable from 'tns-core-modules/data/observable'
import * as Page from 'tns-core-modules/ui/page'
import * as fs from 'tns-core-modules/file-system'
import * as dialogs from 'tns-core-modules/ui/dialogs'
import * as Https from 'nativescript-https'



export function onNavigatingTo(args: Page.NavigatedData) {
let page = args.object as Page.Page
page.bindingContext = Observable.fromObject({ enabled: false })
}

function getRequest(url: string) {
function getRequest(url: string, allowLargeResponse = false) {
Https.request({
url,
method: 'GET',
allowLargeResponse
}).then(function(response) {
console.log('Https.request response', response)
}).catch(function(error) {
console.error('Https.request error', error)
dialogs.alert(error)
})
}

function postRequest(url: string, body: any) {
Https.request({
url, method: 'GET',
url,
method: 'POST',
body
}).then(function(response) {
console.log('Https.request response', response)
}).catch(function(error) {
Expand All @@ -23,7 +35,9 @@ function getRequest(url: string) {
})
}

export function postHttpbin() { postRequest('https://httpbin.org/post', {"foo": "bar", "baz": undefined, "plaz": null}) }
export function getHttpbin() { getRequest('https://httpbin.org/get') }
export function getHttpbinLargeResponse() { getRequest('https://httpbin.org/bytes/100000', true) }
export function getMockbin() { getRequest('https://mockbin.com/request') }

export function enableSSLPinning(args: Observable.EventData) {
Expand Down
8 changes: 6 additions & 2 deletions demo/app/main-page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

<StackLayout class="p-20">
<Label class="h1 text-center" color="{{ enabled ? 'green' : 'red' }}" text="{{ enabled ? 'Httpbin SSL Pinning Enabled' : 'SSL Pinning Disabled' }}" />
<Button text="Httpbin" tap="getHttpbin" class="t-20 btn btn-primary btn-active" />
<Button text="Mockbin" tap="getMockbin" class="t-20 btn btn-primary btn-active" />
<Button text="GET Mockbin" tap="getMockbin" class="t-20 btn btn-primary btn-active" />
<Button text="GET Httpbin" tap="getHttpbin" class="t-20 btn btn-primary btn-active" />
<Button text="GET Httpbin (large response)" tap="getHttpbinLargeResponse" class="t-20 btn btn-primary btn-active" />
<Button text="POST Httpbin " tap="postHttpbin" class="t-20 btn btn-primary btn-active" />
<Button text="Enable Httpbin SSL Pinning" tap="enableSSLPinning" class="t-20 btn btn-primary btn-active" />
<Button text="Disable SSL Pinning" tap="disableSSLPinning" class="t-20 btn btn-primary btn-active" />
<Label text="Here's a spinner to show the main thread is not blocked by network IO" textWrap="true" class="m-20"/>
<ActivityIndicator busy="true" />
</StackLayout>

</Page>
3 changes: 3 additions & 0 deletions demo/nsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"useLegacyWorkflow": false
}
13 changes: 8 additions & 5 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
"nativescript": {
"id": "org.nativescript.demo",
"tns-android": {
"version": "5.1.0"
"version": "5.4.0"
},
"tns-ios": {
"version": "5.4.0"
}
},
"dependencies": {
"nativescript-https": "file:../src",
"nativescript-theme-core": "^1.0.4",
"nativescript-unit-test-runner": "^0.3.4",
"tns-core-modules": "^5.1.0"
"tns-core-modules": "~5.4.0"
},
"devDependencies": {
"jasmine-core": "^2.5.2",
Expand All @@ -18,10 +21,10 @@
"karma-nativescript-launcher": "^0.4.0",
"nativescript-css-loader": "~0.26.1",
"nativescript-dev-typescript": "~0.7.4",
"nativescript-dev-webpack": "~0.17.0",
"tns-platform-declarations": "^5.1.0",
"nativescript-dev-webpack": "0.24.1",
"tns-platform-declarations": "~5.4.0",
"tslint": "~5.11.0",
"typescript": "~2.8.2"
"typescript": "~2.9.0"
},
"scripts": {
"build.plugin": "cd ../src && npm run build",
Expand Down
2 changes: 0 additions & 2 deletions demo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
}
},
"include": [
"../src",
"**/*"
],
"exclude": [
"../src/node_modules",
"node_modules",
"platforms"
],
Expand Down
Loading