All Projects → sneas → Ionic Native Http Connection Backend

sneas / Ionic Native Http Connection Backend

Licence: mit
A solution to CORS issues with Ionic and iOS

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ionic Native Http Connection Backend

Ionic Framework
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
Stars: ✭ 45,802 (+32154.93%)
Mutual labels:  ionic
Ionic4 Starter App Tutorial
Ionic 4 To Do List App. FREE Ionic 4 example app. Learn how to start using Ionic 4 to create a simple app with lists, forms and navigation.
Stars: ✭ 123 (-13.38%)
Mutual labels:  ionic
Ionic3 Start Theme
Ionic 3 Start Theme with 10 Pages, mock data, providers samples, Storage, Http and more...
Stars: ✭ 129 (-9.15%)
Mutual labels:  ionic
Ionic 3 File Transfer Example
📁 File Transfer in Ionic 3 using Ionic Native's File and Transfer modules
Stars: ✭ 113 (-20.42%)
Mutual labels:  ionic
Cnodejs Ionic
The mobile app of https://cnodejs.org made by Ionic 1.x, web demo http://lanceli.com/cnodejs-ionic
Stars: ✭ 1,537 (+982.39%)
Mutual labels:  ionic
Ionic Typescript Starter
📱 Platform and IDE agnostic starter project for building mobile apps with Ionic and TypeScript.
Stars: ✭ 124 (-12.68%)
Mutual labels:  ionic
Ionic Stencil Hn App
Ionic Stencil HackerNews App
Stars: ✭ 105 (-26.06%)
Mutual labels:  ionic
Ionic3 Components
A project full of ionic 3 components and samples - to make life easier :)
Stars: ✭ 1,689 (+1089.44%)
Mutual labels:  ionic
Ionic Super Tabs Example
Example app for ionic-super-tabs library
Stars: ✭ 122 (-14.08%)
Mutual labels:  ionic
Ionic2 Reddit Reader
Ionic 2 Sample App
Stars: ✭ 128 (-9.86%)
Mutual labels:  ionic
Mobiscroll
Cross platform UI controls for progressive web and hybrid apps (plain JS, jQuery, Angular and React)
Stars: ✭ 1,510 (+963.38%)
Mutual labels:  ionic
Ionic Social App
ionic demo application asynchronnous requirejs sass
Stars: ✭ 120 (-15.49%)
Mutual labels:  ionic
Vectoriconsroundup
A comparison between popular vectorial icon fonts
Stars: ✭ 126 (-11.27%)
Mutual labels:  ionic
Blog
lizhonghui's blog
Stars: ✭ 109 (-23.24%)
Mutual labels:  ionic
Simpleddp
An easy to use DDP client library
Stars: ✭ 130 (-8.45%)
Mutual labels:  ionic
Stargazer
Stargazer is a mobile/desktop wallet for the Stellar payments network --
Stars: ✭ 105 (-26.06%)
Mutual labels:  ionic
Chihu2
ionic2-example <吃乎2>混合开发-美食app 🍜 ☕️ 🍦 (This is a support android and apple ionic2 case, a food app)
Stars: ✭ 124 (-12.68%)
Mutual labels:  ionic
Ionic3 Multilevelsidemenu
Ionic 3 demo of a two-level side menu.
Stars: ✭ 141 (-0.7%)
Mutual labels:  ionic
Fluster App
[DEPRECATED] Fluster, your simple search for roommates
Stars: ✭ 134 (-5.63%)
Mutual labels:  ionic
Mybrowser
我的浏览器,基于WKWebView实现的一个iOS浏览器,实现了无图模式、广告拦截、多窗口、扫描二维码、收藏夹/历史、无痕浏览、夜间模式等功能...
Stars: ✭ 127 (-10.56%)
Mutual labels:  wkwebview

ionic-native-http-connection-backend

version MIT License

This library adds @ionic-native/http (when available) as a connection backend to Angular's Http and HttpClient

Motivation

Now that Apple promotes/requires the use of WKWebView instead of the deprecated UIWebView, Ionic has switched newly created apps over via their cordova-plugin-ionic-webview (and Cordova offers it via their cordova-plugin-wkwebview-engine). That causes requests that used to work just fine to fail with CORS errors.

The real solution of course is to fix the CORS issues server side - but this may not be possible with e.g. 3rd party APIs.

Even though there is a way to solve CORS issues without changing server's response header by using @ionic-native/http, this only works on device and doesn't provide all the power of Angular's Http and HttpClient.

How it works

  • The library provides a HttpBackend interface for Angular's HttpClient
  • This HttpBackend interface tries to use @ionic-native/http whenever it is possible (= on device with installed plugin)
  • If HttpBackend finds it impossible to use @ionic-native/http, it falls back to standard Angular code (HttpXhrBackend, which uses XmlHttpRequest)

This strategy allows developers to use Angular's HttpClient transparently in both environments: Browser and Device.

Installation

npm install --save ionic-native-http-connection-backend

Then follow instructions at https://ionicframework.com/docs/native/http/#installation

Usage

Add NativeHttpModule, NativeHttpBackend and NativeHttpFallback into the application's module

import { NgModule } from '@angular/core';
import { HttpBackend, HttpXhrBackend } from '@angular/common/http';
import { NativeHttpModule, NativeHttpBackend, NativeHttpFallback } from 'ionic-native-http-connection-backend';
import { Platform } from '@ionic/angular';

@NgModule({
    declarations: [],
    imports: [
        NativeHttpModule
    ],
    bootstrap: [],
    entryComponents: [],
    providers: [
        {provide: HttpBackend, useClass: NativeHttpFallback, deps: [Platform, NativeHttpBackend, HttpXhrBackend]},
    ],
})
export class AppModule {
}

Contributing

Contributing guidelines could be found in CONTRIBUTING.md

Troubleshooting

TROUBLESHOOTING.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].