Launch Websites With Ionic 2 Using The InAppBrowser

https://github.com/apache/cordova-plugin-inappbrowser


inappbrowser - http://ionicframework.com/docs/native/in-app-browser/


In App Browser

$ ionic plugin add --save cordova-plugin-inappbrowser
$ npm install --save @ionic-native/in-app-browser

Repo: https://github.com/apache/cordova-plugin-inappbrowser

Launches in app Browser




Create a Fresh Ionic 2 Project
Shell
1
2
3
4
ionic start ExampleProject blank --v2
cd ExampleProject
ionic platform add ios
ionic platform add android



1
cordova plugin add cordova-plugin-inappbrowser


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import {Platform, Page} from 'ionic-framework/ionic';
 
 
@Page({
    templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
 
    static get parameters() {
        return [[Platform]];
    }
 
    constructor(platform) {
        this.platform = platform;
    }
 
    launch(url) {
        this.platform.ready().then(() => {
            cordova.InAppBrowser.open(url, "_system", "location=true");
        });
    }
}






.

Posted by 홍반장水 홍반장水

ionic project 생성시 이제 default가 version 2로 지정됨


http://ionicframework.com/getting-started/ 들어가보면 기존에는 


버전 2로 하려면 아래와 같이 생성했었는데, 

1
ionic start ExampleProject blank --v2

이제는 버전 1로 만들고 싶을때 아래와 같이 해야 한다. 

1
ionic start ExampleProject blank --v1


단, npm install  한번 더 하고 테스트 해보시길. 

> npm install -g cordova ionic


device에 넣을때에도 ionic run android 가 아니라 

> ionic cordova run android




.

Posted by 홍반장水 홍반장水

cordova-plugin-inappbrowser


https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/


Installation

cordova plugin add cordova-plugin-inappbrowser

If you want all page loads in your app to go through the InAppBrowser, you can simply hook window.open during initialization. For example:

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    window.open = cordova.InAppBrowser.open;
}

cordova.InAppBrowser.open

Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.

var ref = cordova.InAppBrowser.open(url, target, options);
  • ref: Reference to the InAppBrowser window when the target is set to '_blank'(InAppBrowser)

  • url: The URL to load (String). Call encodeURI() on this if the URL contains Unicode characters.

  • target: The target in which to load the URL, an optional parameter that defaults to _self(String)

    • _self: Opens in the Cordova WebView if the URL is in the white list, otherwise it opens in the InAppBrowser.
    • _blank: Opens in the InAppBrowser.
    • _system: Opens in the system's web browser.
  • options: Options for the InAppBrowser. Optional, defaulting to: location=yes(String)

    The options string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive. All platforms support the value below:

    • location: Set to yes or no to turn the InAppBrowser's location bar on or off.

    Android only:

    • hidden: set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to no (default) to have the browser open and load normally.
    • clearcache: set to yes to have the browser's cookie cache cleared before the new window is opened
    • clearsessioncache: set to yes to have the session cookie cache cleared before the new window is opened
    • zoom: set to yes to show Android browser's zoom controls, set to no to hide them. Default value is yes.
    • hardwareback: set to yes to use the hardware back button to navigate backwards through the InAppBrowser's history. If there is no previous page, the InAppBrowser will close. The default value is yes, so you must set it to no if you want the back button to simply close the InAppBrowser.
    • mediaPlaybackRequiresUserAction: Set to yes to prevent HTML5 audio or video from autoplaying (defaults to no).
    • shouldPauseOnSuspend: Set to yes to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in CB-11013).
    • useWideViewPort: Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is no, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is yes and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. (defaults to yes).

    iOS only:

    • closebuttoncaption: set to a string to use as the Done button's caption. Note that you need to localize this value yourself.
    • disallowoverscroll: Set to yes or no (default is no). Turns on/off the UIWebViewBounce property.
    • hidden: set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to no (default) to have the browser open and load normally.
    • clearcache: set to yes to have the browser's cookie cache cleared before the new window is opened
    • clearsessioncache: set to yes to have the session cookie cache cleared before the new window is opened
    • toolbar: set to yes or no to turn the toolbar on or off for the InAppBrowser (defaults to yes)
    • enableViewportScale: Set to yes or no to prevent viewport scaling through a meta tag (defaults to no).
    • mediaPlaybackRequiresUserAction: Set to yes to prevent HTML5 audio or video from autoplaying (defaults to no).
    • allowInlineMediaPlayback: Set to yes or no to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's video element must also include the webkit-playsinline attribute (defaults to no)
    • keyboardDisplayRequiresUserAction: Set to yes or no to open the keyboard when form elements receive focus via JavaScript's focus() call (defaults to yes).
    • suppressesIncrementalRendering: Set to yes or no to wait until all new view content is received before being rendered (defaults to no).
    • presentationstyle: Set to pagesheetformsheet or fullscreen to set the presentation style (defaults to fullscreen).
    • transitionstyle: Set to fliphorizontalcrossdissolve or coververtical to set the transition style (defaults to coververtical).
    • toolbarposition: Set to top or bottom (default is bottom). Causes the toolbar to be at the top or bottom of the window.

    Windows only:

    • hidden: set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to no (default) to have the browser open and load normally.
    • fullscreen: set to yes to create the browser control without a border around it. Please note that if location=no is also specified, there will be no control presented to user to close IAB window.
    • hardwareback: works the same way as on Android platform.

Supported Platforms

  • Amazon Fire OS
  • Android
  • BlackBerry 10
  • Firefox OS
  • iOS
  • OSX
  • Windows 8 and 8.1
  • Windows Phone 7 and 8
  • Browser




.

Posted by 홍반장水 홍반장水

https://github.com/driftyco/cordova-plugin-wkwebview-engine#installation-instructions


코르도바 WKWebView 엔진

이 플러그인은 Apache Cordova WKWebView 플러그인의 확장 입니다. 여기에는 몇 가지 DOM 예외 문제와 함께 XHR 요청을 둘러싼 일부 문제를 해결하기위한 개선 사항이 포함되어 있습니다. Ionic은 Cordova 팀과 협력하여 업데이트를 공식 Cordova 플러그인에 병합하는 최종 목표로 이러한 변경 사항을 완전히 테스트합니다. 베타 테스트 기간이 끝나면 WKWebView 플러그인을 Ionic 기본값으로 설정하여 모든 사용자가 UIWebView에 비해이 플러그인의 향상된 성능을 쉽게 이용할 수있게하는 것이 중요합니다.

이 플러그인은 iOS 9 이상 만 지원하며 iOS 8의 UIWebView로 대체됩니다.

WKWebView 플러그인은 iOS에서만 사용되므로 cordova-ios플랫폼이 설치 되어 있는지 확인하십시오 또한 cordova-ios플랫폼 버전이 같 4.0거나 커야합니다.

설치 지침

최신 Cordova CLI가 설치되어 있는지 확인하십시오 (Sudo가 필요할 수도 있음).

npm install cordova -g

ios플랫폼이 추가 되었는지 확인하십시오 .

ionic platform ls

iOS 플랫폼이 목록에 없으면 다음 명령을 실행하십시오.

ionic platform add ios

iOS 플랫폼이 설치되었지만 버전이 < 4.x인 경우 다음 명령을 실행하십시오.

ionic platform update ios
ionic plugin save           # creates backup of existing plugins
rm -rf ./plugins            # delete plugins directory
ionic prepare               # re-install plugins compatible with cordova-ios 4.x

WKWebViewPlugin 설치 :

ionic plugin add https://github.com/driftyco/cordova-plugin-wkwebview-engine.git --save

노트 :

이미 아파치 / cordova-plugin-wkwebview-engine을 설치 했다면 이 버전을 사용하기 전에 제거해야합니다.

ionic plugin rm cordova-plugin-wkwebview-engine

플랫폼 구축 :

ionic prepare

iOS 9 또는 10 기기에서 앱 테스트 :

ionic run ios

iOS에 WKWebView가 설치되었는지 확인하는 쉬운 방법은 window.indexedDB존재하는지 확인하는 것입니다. 예 :

if (window.indexedDB) {
   console.log("I'm in WKWebView!");
} else {
   console.log("I'm in UIWebView");
}

필요한 사용 권한

config.xml에 다음 내용이 포함되어 있지 않으면 WKWebView가 완전히 실행되지 않을 수 있습니다 (deviceready 이벤트가 실행되지 않을 수 있음).

config.xml

<allow-navigation href="http://localhost:8080/*"/>
<feature name="CDVWKWebViewEngine">
  <param name="ios-package" value="CDVWKWebViewEngine" />
</feature>

<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />


Posted by 홍반장水 홍반장水
Angular 2와 Ionic 2가 포함 된 모바일 앱 제작


https://codequs.com/p/rygc88xt/build-a-mobile-app-with-angular-2-and-ionic-2/


The Ionic Framework enables the creation of cross platform mobile applications with HTML, CSS and JavaScript(Angular). Ionic 1 was built with Angular 1.*, and with the upcoming release of Angular 2, the second major version of Ionic is also imminent.

Automate JavaScript workflow with Gulp


Ionic 2 is still in beta, but if you are looking to build cross-platform apps quickly, and you already know Angluar 2 or JavaScript, this guide will get you up to speed.

Why Choose Ionic?

You already know HTML/CSS/JS

You can leverage the skills you already have from developing web applications with HTML, JavaScript and CSS to build cross-platform mobile apps. If you work with Angular 2, this will be a seamless transitions.

Take advantage of Progressive Web Apps

Google has been talking about Progressive Web Apps. These are simply web apps that give an app-like user experience to users, and are built with Web Technologies and Ionic 2 is at the fore front of implementing this. An example progressive web app(not built with ionic) is the google io web app: Visit the app in your chrome browser in your phone, click on menu and tap Add to Home Screen. You’ll then be able to load it as an app from your home screen.

Target all major mobile platforms

If you need to quickly build an app for all major mobile platforms (Android, iOS and Windows Phone), having one codebase may be the fastest way to do it, and Ionic is perfect for such a scenario. Updating the app, or rolling uout updates is just as easy as editing one code base.

Native Functionality is easy to implement

There are a lot of cordova plugins that allow you to include native functionality of the platform you are building for. The Ionic 2 documentation has implimentation examples of some of the plugins.

What We’ll be Building

We will build a simple app that consumes the github api. Our app will list github users, offer a search box for searching users, and be able to view the number of followers, repos, and gists the user has.

Below is a short video of the finished app.







.

Posted by 홍반장水 홍반장水