diff --git a/.gitignore b/.gitignore index f2ad902..5c1632f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/README.md b/README.md index f131b68..862ffac 100644 --- a/README.md +++ b/README.md @@ -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 ------------ | ------------- diff --git a/demo/app/App_Resources/iOS/build.xcconfig b/demo/app/App_Resources/iOS/build.xcconfig index 0562055..6961c55 100644 --- a/demo/app/App_Resources/iOS/build.xcconfig +++ b/demo/app/App_Resources/iOS/build.xcconfig @@ -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; diff --git a/demo/app/assets/httpbin.org.cer b/demo/app/assets/httpbin.org.cer index e003b59..ec44c38 100644 Binary files a/demo/app/assets/httpbin.org.cer and b/demo/app/assets/httpbin.org.cer differ diff --git a/demo/app/main-page.ts b/demo/app/main-page.ts index b1c20fd..1fa633e 100644 --- a/demo/app/main-page.ts +++ b/demo/app/main-page.ts @@ -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) { @@ -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) { diff --git a/demo/app/main-page.xml b/demo/app/main-page.xml index 879c258..df02365 100644 --- a/demo/app/main-page.xml +++ b/demo/app/main-page.xml @@ -5,10 +5,14 @@