├── android ├── app │ ├── .gitignore │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ ├── colors.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ │ ├── ic_launcher.xml │ │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── layout │ │ │ │ │ └── activity_main.xml │ │ │ │ ├── drawable-v24 │ │ │ │ │ └── ic_launcher_foreground.xml │ │ │ │ └── drawable │ │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── java │ │ │ │ └── br │ │ │ │ │ └── com │ │ │ │ │ └── mfdeveloper │ │ │ │ │ └── cordova │ │ │ │ │ └── MainActivity.java │ │ │ └── AndroidManifest.xml │ │ ├── test │ │ │ └── java │ │ │ │ └── br │ │ │ │ └── com │ │ │ │ └── mfdeveloper │ │ │ │ └── cordova │ │ │ │ └── ExampleUnitTest.java │ │ └── androidTest │ │ │ └── java │ │ │ └── br │ │ │ └── com │ │ │ └── mfdeveloper │ │ │ └── cordova │ │ │ └── ExampleInstrumentedTest.java │ ├── proguard-rules.pro │ └── build.gradle ├── lib │ ├── .gitignore │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ └── values │ │ │ │ │ └── strings.xml │ │ │ └── AndroidManifest.xml │ │ ├── test │ │ │ └── java │ │ │ │ └── br │ │ │ │ └── com │ │ │ │ └── mfdeveloper │ │ │ │ └── lib │ │ │ │ └── ExampleUnitTest.java │ │ └── androidTest │ │ │ └── java │ │ │ └── br │ │ │ └── com │ │ │ └── mfdeveloper │ │ │ └── lib │ │ │ └── ExampleInstrumentedTest.java │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .idea │ ├── modules.xml │ ├── runConfigurations.xml │ ├── gradle.xml │ └── misc.xml ├── gradle.properties ├── build.gradle ├── gradlew.bat ├── .gitignore └── gradlew ├── ionic-example ├── src │ ├── app │ │ ├── app.component.scss │ │ ├── home │ │ │ ├── home.page.scss │ │ │ ├── home.page.html │ │ │ ├── home.module.ts │ │ │ ├── home.page.spec.ts │ │ │ └── home.page.ts │ │ ├── app.component.html │ │ ├── app-routing.module.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ └── app.component.spec.ts │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── assets │ │ ├── icon │ │ │ └── favicon.png │ │ └── shapes.svg │ ├── zone-flags.ts │ ├── main.ts │ ├── test.ts │ ├── index.html │ ├── global.scss │ ├── theme │ │ └── variables.scss │ └── polyfills.ts ├── resources │ ├── icon.png │ ├── splash.png │ ├── ios │ │ ├── icon │ │ │ ├── icon.png │ │ │ ├── icon-20.png │ │ │ ├── icon-29.png │ │ │ ├── icon-40.png │ │ │ ├── icon-50.png │ │ │ ├── icon-60.png │ │ │ ├── icon-72.png │ │ │ ├── icon-76.png │ │ │ ├── icon@2x.png │ │ │ ├── icon-1024.png │ │ │ ├── icon-20@2x.png │ │ │ ├── icon-20@3x.png │ │ │ ├── icon-24@2x.png │ │ │ ├── icon-29@2x.png │ │ │ ├── icon-29@3x.png │ │ │ ├── icon-40@2x.png │ │ │ ├── icon-40@3x.png │ │ │ ├── icon-44@2x.png │ │ │ ├── icon-50@2x.png │ │ │ ├── icon-60@2x.png │ │ │ ├── icon-60@3x.png │ │ │ ├── icon-72@2x.png │ │ │ ├── icon-76@2x.png │ │ │ ├── icon-86@2x.png │ │ │ ├── icon-98@2x.png │ │ │ ├── icon-small.png │ │ │ ├── icon-27.5@2x.png │ │ │ ├── icon-83.5@2x.png │ │ │ ├── icon-small@2x.png │ │ │ └── icon-small@3x.png │ │ └── splash │ │ │ ├── Default-2436h.png │ │ │ ├── Default-667h.png │ │ │ ├── Default-736h.png │ │ │ ├── Default~iphone.png │ │ │ ├── Default@2x~iphone.png │ │ │ ├── Default-Portrait~ipad.png │ │ │ ├── Default-568h@2x~iphone.png │ │ │ ├── Default-Landscape-2436h.png │ │ │ ├── Default-Landscape-736h.png │ │ │ ├── Default-Landscape~ipad.png │ │ │ ├── Default-Landscape@2x~ipad.png │ │ │ ├── Default-Landscape@~ipadpro.png │ │ │ ├── Default-Portrait@2x~ipad.png │ │ │ ├── Default-Portrait@~ipadpro.png │ │ │ └── Default@2x~universal~anyany.png │ ├── android │ │ ├── icon │ │ │ ├── drawable-hdpi-icon.png │ │ │ ├── drawable-ldpi-icon.png │ │ │ ├── drawable-mdpi-icon.png │ │ │ ├── drawable-xhdpi-icon.png │ │ │ ├── drawable-xxhdpi-icon.png │ │ │ └── drawable-xxxhdpi-icon.png │ │ ├── splash │ │ │ ├── drawable-land-hdpi-screen.png │ │ │ ├── drawable-land-ldpi-screen.png │ │ │ ├── drawable-land-mdpi-screen.png │ │ │ ├── drawable-land-xhdpi-screen.png │ │ │ ├── drawable-land-xxhdpi-screen.png │ │ │ ├── drawable-port-hdpi-screen.png │ │ │ ├── drawable-port-ldpi-screen.png │ │ │ ├── drawable-port-mdpi-screen.png │ │ │ ├── drawable-port-xhdpi-screen.png │ │ │ ├── drawable-port-xxhdpi-screen.png │ │ │ ├── drawable-land-xxxhdpi-screen.png │ │ │ └── drawable-port-xxxhdpi-screen.png │ │ └── xml │ │ │ └── network_security_config.xml │ └── README.md ├── ionic.config.json ├── e2e │ ├── src │ │ ├── app.po.ts │ │ └── app.e2e-spec.ts │ ├── tsconfig.json │ └── protractor.conf.js ├── tsconfig.app.json ├── tsconfig.spec.json ├── browserslist ├── .gitignore ├── tsconfig.json ├── karma.conf.js ├── tslint.json ├── package.json ├── angular.json └── config.xml ├── .npmignore ├── icons ├── ios.png └── android.png ├── types ├── tslint.json ├── test.ts ├── tsconfig.json └── index.d.ts ├── .vscode └── extensions.json ├── www ├── android │ └── plugin.nativeview.js └── plugin.nativeview.js ├── src ├── ios │ ├── CDVNativeView.h │ └── CDVNativeView.m └── android │ └── br │ └── com │ └── mfdeveloper │ └── cordova │ └── NativeView.java ├── .gitignore ├── LICENSE ├── package.json ├── plugin.xml ├── cordova-plugin-nativeview.podspec ├── README.md └── scripts └── after.prepare.js /android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android/lib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /ionic-example/src/app/app.component.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ionic-example/src/app/home/home.page.scss: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | android/ 2 | ionic-example/ 3 | .vscode -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':lib' 2 | -------------------------------------------------------------------------------- /icons/ios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/icons/ios.png -------------------------------------------------------------------------------- /icons/android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/icons/android.png -------------------------------------------------------------------------------- /ionic-example/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /ionic-example/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /android/lib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Lib 3 | 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | NativeViewExample 3 | 4 | -------------------------------------------------------------------------------- /ionic-example/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/icon.png -------------------------------------------------------------------------------- /ionic-example/resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/splash.png -------------------------------------------------------------------------------- /ionic-example/ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-example", 3 | "integrations": { 4 | "cordova": {} 5 | }, 6 | "type": "angular" 7 | } 8 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/lib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /ionic-example/src/assets/icon/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/src/assets/icon/favicon.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-20.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-29.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-1024.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-20@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-20@3x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-24@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-24@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-29@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-29@3x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-44@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-44@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-86@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-86@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-98@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-98@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-27.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-27.5@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", // Or "dtslint/dt.json" if on DefinitelyTyped 3 | "rules": { 4 | "semicolon": true 5 | } 6 | } -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-2436h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-2436h.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ionic-example/resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /ionic-example/resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /ionic-example/resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /ionic-example/resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ionic-example/resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /ionic-example/resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-Landscape-2436h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-Landscape-2436h.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /ionic-example/src/zone-flags.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Prevents Angular change detection from 3 | * running with certain Web Component callbacks 4 | */ 5 | (window as any).__Zone_disable_customElements = true; 6 | -------------------------------------------------------------------------------- /ionic-example/resources/ios/splash/Default@2x~universal~anyany.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/ios/splash/Default@2x~universal~anyany.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /ionic-example/resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mfdeveloper/cordova-plugin-nativeview/HEAD/ionic-example/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": [ 5 | "vsmobile.cordova-tools", 6 | "agenric.cocoapods-snippets" 7 | ] 8 | } -------------------------------------------------------------------------------- /android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /types/test.ts: -------------------------------------------------------------------------------- 1 | import './index.d'; 2 | 3 | // $ExpectType Promise 4 | cordova.plugins.NativeView.show({ 5 | package: 'my.package.test', 6 | className: 'MyClass' 7 | }); 8 | 9 | // $ExpectError 10 | cordova.plugins.NativeView.show({ 11 | package: 'aaa' 12 | }); 13 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Aug 20 14:10:29 BRT 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /ionic-example/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.deepCss('app-root ion-content')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /ionic-example/e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ionic-example/resources/android/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | localhost 5 | 6 | 7 | -------------------------------------------------------------------------------- /ionic-example/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "include": [ 8 | "src/**/*.ts" 9 | ], 10 | "exclude": [ 11 | "src/test.ts", 12 | "src/**/*.spec.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ionic-example/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('new App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should be blank', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toContain('The world is your oyster.'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /ionic-example/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/zone-flags.ts", 13 | "src/polyfills.ts" 14 | ], 15 | "include": [ 16 | "src/**/*.spec.ts", 17 | "src/**/*.d.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /ionic-example/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /android/app/src/main/java/br/com/mfdeveloper/cordova/MainActivity.java: -------------------------------------------------------------------------------- 1 | package br.com.mfdeveloper.cordova; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | public class MainActivity extends AppCompatActivity { 7 | 8 | @Override 9 | protected void onCreate(Bundle savedInstanceState) { 10 | super.onCreate(savedInstanceState); 11 | setContentView(R.layout.activity_main); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ionic-example/resources/README.md: -------------------------------------------------------------------------------- 1 | These are Cordova resources. You can replace icon.png and splash.png and run 2 | `ionic cordova resources` to generate custom icons and splash screens for your 3 | app. See `ionic cordova resources --help` for details. 4 | 5 | Cordova reference documentation: 6 | 7 | - Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html 8 | - Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/ 9 | -------------------------------------------------------------------------------- /www/android/plugin.nativeview.js: -------------------------------------------------------------------------------- 1 | var cordova = require('cordova'); 2 | 3 | var PLUGIN_NAME = 'NativeViewAndroid'; 4 | 5 | function NativeViewAndroid() { 6 | 7 | this.getBuildVariant = function (config, success, error) { 8 | return new Promise(function (resolve, reject) { 9 | cordova.exec(success || resolve, error || reject, PLUGIN_NAME, 'getBuildVariant', [config]); 10 | }); 11 | }; 12 | } 13 | 14 | module.exports = new NativeViewAndroid(); 15 | -------------------------------------------------------------------------------- /ionic-example/browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. 13 | -------------------------------------------------------------------------------- /android/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /android/lib/src/test/java/br/com/mfdeveloper/lib/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package br.com.mfdeveloper.lib; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /ionic-example/src/app/home/home.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ionic Blank 5 | 6 | 7 | 8 | 9 | 10 | 11 | The world is your oyster. 12 | If you get lost, the docs will be your guide. 13 | 14 | Open native 15 | 16 | 17 | -------------------------------------------------------------------------------- /android/app/src/test/java/br/com/mfdeveloper/cordova/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package br.com.mfdeveloper.cordova; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /ionic-example/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; 3 | 4 | const routes: Routes = [ 5 | { path: '', redirectTo: 'home', pathMatch: 'full' }, 6 | { path: 'home', loadChildren: () => import('./home/home.module').then( m => m.HomePageModule)}, 7 | ]; 8 | 9 | @NgModule({ 10 | imports: [ 11 | RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) 12 | ], 13 | exports: [RouterModule] 14 | }) 15 | export class AppRoutingModule { } 16 | -------------------------------------------------------------------------------- /ionic-example/.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .ionic/ 17 | .sourcemaps/ 18 | .sass-cache/ 19 | .tmp/ 20 | .versions/ 21 | coverage/ 22 | www/ 23 | dist/ 24 | node_modules/ 25 | tmp/ 26 | temp/ 27 | platforms/ 28 | plugins/ 29 | plugins/android.json 30 | plugins/ios.json 31 | $RECYCLE.BIN/ 32 | 33 | .DS_Store 34 | Thumbs.db 35 | UserInterfaceState.xcuserstate 36 | -------------------------------------------------------------------------------- /android/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ionic-example/src/app/home/home.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { IonicModule } from '@ionic/angular'; 4 | import { FormsModule } from '@angular/forms'; 5 | import { RouterModule } from '@angular/router'; 6 | 7 | import { HomePage } from './home.page'; 8 | 9 | @NgModule({ 10 | imports: [ 11 | CommonModule, 12 | FormsModule, 13 | IonicModule, 14 | RouterModule.forChild([ 15 | { 16 | path: '', 17 | component: HomePage 18 | } 19 | ]) 20 | ], 21 | declarations: [HomePage] 22 | }) 23 | export class HomePageModule {} 24 | -------------------------------------------------------------------------------- /types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "lib": ["es6", "dom"], 6 | "noImplicitAny": true, 7 | "noImplicitThis": true, 8 | "strictNullChecks": true, 9 | "strictFunctionTypes": true, 10 | "noEmit": true, 11 | // If the library is an external module (uses `export`), this allows your test file to import "mylib" instead of "./index". 12 | // If the library is global (cannot be imported via `import` or `require`), leave this out. 13 | "baseUrl": "." 14 | }, 15 | "include": [ 16 | "./types/*.d.ts" 17 | ] 18 | } -------------------------------------------------------------------------------- /ionic-example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "esnext", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | }, 22 | "angularCompilerOptions": { 23 | "fullTemplateTypeCheck": true, 24 | "strictInjectionParameters": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ionic-example/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /ionic-example/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /ionic-example/src/app/home/home.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { IonicModule } from '@ionic/angular'; 3 | 4 | import { HomePage } from './home.page'; 5 | 6 | describe('HomePage', () => { 7 | let component: HomePage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ HomePage ], 13 | imports: [IonicModule.forRoot()] 14 | }).compileComponents(); 15 | 16 | fixture = TestBed.createComponent(HomePage); 17 | component = fixture.componentInstance; 18 | fixture.detectChanges(); 19 | })); 20 | 21 | it('should create', () => { 22 | expect(component).toBeTruthy(); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /ionic-example/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { Platform } from '@ionic/angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 5 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 6 | 7 | @Component({ 8 | selector: 'app-root', 9 | templateUrl: 'app.component.html', 10 | styleUrls: ['app.component.scss'] 11 | }) 12 | export class AppComponent { 13 | constructor( 14 | private platform: Platform, 15 | private splashScreen: SplashScreen, 16 | private statusBar: StatusBar 17 | ) { 18 | this.initializeApp(); 19 | } 20 | 21 | initializeApp() { 22 | this.platform.ready().then(() => { 23 | this.statusBar.styleDefault(); 24 | this.splashScreen.hide(); 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ionic-example/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Ionic App 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | maven { 9 | url 'https://jitpack.io' 10 | } 11 | } 12 | dependencies { 13 | classpath 'com.android.tools.build:gradle:3.4.2' 14 | 15 | 16 | // NOTE: Do not place your application dependencies here; they belong 17 | // in the individual module build.gradle files 18 | } 19 | } 20 | 21 | plugins { 22 | 23 | id "com.github.dcendents.android-maven" version "2.0" 24 | } 25 | 26 | allprojects { 27 | repositories { 28 | google() 29 | jcenter() 30 | 31 | maven { 32 | url 'https://jitpack.io' 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /android/lib/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | -------------------------------------------------------------------------------- /src/ios/CDVNativeView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CDVNativeView.h 3 | // 4 | // Created by Michel Felipe on 05/09/17. 5 | // 6 | // 7 | 8 | // Reference: https://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown 9 | #define SuppressPerformSelectorLeakWarning(Stuff) \ 10 | do { \ 11 | _Pragma("clang diagnostic push") \ 12 | _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \ 13 | Stuff; \ 14 | _Pragma("clang diagnostic pop") \ 15 | } while (0) 16 | 17 | #import 18 | 19 | @interface CDVNativeView : CDVPlugin 20 | 21 | @property (strong, nonatomic) NSDictionary *resultExceptions; 22 | 23 | - (void)show:(CDVInvokedUrlCommand*)command; 24 | - (void)checkIfAppInstalled:(CDVInvokedUrlCommand*)command; 25 | - (void)showMarket:(CDVInvokedUrlCommand*)command; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /ionic-example/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { RouteReuseStrategy } from '@angular/router'; 4 | 5 | import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; 6 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 7 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 8 | 9 | import { AppComponent } from './app.component'; 10 | import { AppRoutingModule } from './app-routing.module'; 11 | 12 | @NgModule({ 13 | declarations: [AppComponent], 14 | entryComponents: [], 15 | imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule], 16 | providers: [ 17 | StatusBar, 18 | SplashScreen, 19 | { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } 20 | ], 21 | bootstrap: [AppComponent] 22 | }) 23 | export class AppModule {} 24 | -------------------------------------------------------------------------------- /ionic-example/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /android/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /android/lib/src/androidTest/java/br/com/mfdeveloper/lib/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package br.com.mfdeveloper.lib; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("br.com.mfdeveloper.lib.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android/app/src/androidTest/java/br/com/mfdeveloper/cordova/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package br.com.mfdeveloper.cordova; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("br.com.mfdeveloper.cordova", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ionic-example/src/app/home/home.page.ts: -------------------------------------------------------------------------------- 1 | import { Platform } from '@ionic/angular'; 2 | import { Component } from '@angular/core'; 3 | 4 | 5 | @Component({ 6 | selector: 'app-home', 7 | templateUrl: 'home.page.html', 8 | styleUrls: ['home.page.scss'], 9 | }) 10 | export class HomePage { 11 | 12 | nativeScreens = { 13 | ios: { 14 | viewControllerName: 'MyViewController' 15 | }, 16 | android: { 17 | packageName: 'org.example', 18 | className: 'MyActivity' 19 | } 20 | }; 21 | 22 | constructor(protected platform: Platform) {} 23 | 24 | openNative() { 25 | this.platform.ready().then(_ => { 26 | (cordova.plugins as any).NativeView.show(this.nativeScreens[this.currentPlatform]) 27 | .then(result => { 28 | console.dir(result); 29 | }); 30 | }); 31 | } 32 | 33 | get currentPlatform(): string { 34 | return this.platform.platforms().find(p => p === 'android' || p === 'ios'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ionic-example/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | defaultConfig { 6 | applicationId "br.com.mfdeveloper.cordova" 7 | minSdkVersion 19 8 | targetSdkVersion 27 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:27.1.1' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 28 | implementation 'com.github.mfdeveloper:cordova-android:7.1.1' 29 | implementation project(':lib') 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2010-2017 Google, Inc. http://angularjs.org 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /ionic-example/src/assets/shapes.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ionic-example/src/global.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * App Global CSS 3 | * ---------------------------------------------------------------------------- 4 | * Put style rules here that you want to apply globally. These styles are for 5 | * the entire app and not just one component. Additionally, this file can be 6 | * used as an entry point to import other CSS/Sass files to be included in the 7 | * output CSS. 8 | * For more information on global stylesheets, visit the documentation: 9 | * https://ionicframework.com/docs/layout/global-stylesheets 10 | */ 11 | 12 | /* Core CSS required for Ionic components to work properly */ 13 | @import "~@ionic/angular/css/core.css"; 14 | 15 | /* Basic CSS for apps built with Ionic */ 16 | @import "~@ionic/angular/css/normalize.css"; 17 | @import "~@ionic/angular/css/structure.css"; 18 | @import "~@ionic/angular/css/typography.css"; 19 | @import '~@ionic/angular/css/display.css'; 20 | 21 | /* Optional CSS utils that can be commented out */ 22 | @import "~@ionic/angular/css/padding.css"; 23 | @import "~@ionic/angular/css/float-elements.css"; 24 | @import "~@ionic/angular/css/text-alignment.css"; 25 | @import "~@ionic/angular/css/text-transformation.css"; 26 | @import "~@ionic/angular/css/flex-utils.css"; 27 | -------------------------------------------------------------------------------- /android/lib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | group = 'com.github.mfdeveloper' 4 | 5 | android { 6 | compileSdkVersion 27 7 | 8 | sourceSets { 9 | main { 10 | java.srcDirs = ['../../src/android', 'src/main/java'] 11 | } 12 | } 13 | 14 | defaultConfig { 15 | minSdkVersion 19 16 | targetSdkVersion 27 17 | versionCode 1 18 | versionName "1.0" 19 | 20 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 21 | 22 | } 23 | 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | 31 | } 32 | 33 | dependencies { 34 | implementation fileTree(dir: 'libs', include: ['*.jar']) 35 | 36 | implementation 'com.android.support:appcompat-v7:27.1.1' 37 | testImplementation 'junit:junit:4.12' 38 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 39 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 40 | 41 | implementation ('com.github.mfdeveloper:cordova-android:7.1.1') 42 | } 43 | -------------------------------------------------------------------------------- /www/plugin.nativeview.js: -------------------------------------------------------------------------------- 1 | var cordova = require('cordova'); 2 | 3 | var PLUGIN_NAME = 'NativeView'; 4 | 5 | function NativeView() { 6 | 7 | this.show = function (packageOrClass, className, extraParams, success, error) { 8 | return new Promise(function (resolve, reject) { 9 | 10 | var params = className ? [packageOrClass, className] : [packageOrClass]; 11 | if (extraParams) { 12 | if (extraParams instanceof Function) { 13 | error = success; 14 | success = extraParams; 15 | } else { 16 | params.push(JSON.stringify(extraParams)); 17 | } 18 | } 19 | 20 | cordova.exec(success || resolve, error || reject, PLUGIN_NAME, 'show', params); 21 | }); 22 | }; 23 | 24 | this.checkIfAppInstalled = function (config, success, error) { 25 | return new Promise(function (resolve, reject) { 26 | cordova.exec(success || resolve, error || reject, PLUGIN_NAME, 'checkIfAppInstalled', config ? [config] : []); 27 | }); 28 | }; 29 | 30 | this.showMarket = function (config, success, error) { 31 | return new Promise(function (resolve, reject) { 32 | cordova.exec(success || resolve, error || reject, PLUGIN_NAME, 'showMarket', config ? [config] : []); 33 | }); 34 | }; 35 | }; 36 | 37 | module.exports = new NativeView(); 38 | 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-plugin-nativeview", 3 | "version": "1.0.12", 4 | "typings": "types", 5 | "types": "types", 6 | "description": "Start or Back to a native screen/page", 7 | "author": { 8 | "name": "Michel Felipe", 9 | "email": "mfelipeof@gmail.com" 10 | }, 11 | "cordova": { 12 | "id": "cordova-plugin-nativeview", 13 | "platforms": [ 14 | "android", 15 | "ios" 16 | ] 17 | }, 18 | "engines": { 19 | "cordova": ">=6.0.0", 20 | "cordova-res": ">=0.6.0" 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "https://github.com/mfdeveloper/cordova-plugin-nativeview" 25 | }, 26 | "bugs": { 27 | "url": "https://github.com/mfdeveloper/cordova-plugin-nativeview/issues" 28 | }, 29 | "keywords": [ 30 | "cordova", 31 | "activity", 32 | "back", 33 | "UIViewController", 34 | "ecosystem:cordova", 35 | "cordova-android", 36 | "cordova-ios" 37 | ], 38 | "license": "MIT", 39 | "devDependencies": { 40 | "@types/cordova": "0.0.34", 41 | "cached-path-relative": ">=1.0.2", 42 | "cryptiles": ">=4.1.2", 43 | "dtslint": "^0.9.1", 44 | "fstream": "^1.0.12", 45 | "hoek": ">=4.2.1", 46 | "lodash": "^4.17.15", 47 | "np": "^3.0.4", 48 | "plugman": "^2.0.0", 49 | "tar": "^4.4.10", 50 | "tunnel-agent": "^0.6.0", 51 | "typescript": "^3.5.3", 52 | "acorn": ">=5.7.4", 53 | "kind-of": ">=6.0.3", 54 | "minimist": ">=1.2.2" 55 | }, 56 | "scripts": { 57 | "release": "./node_modules/.bin/np", 58 | "dtslint": "dtslint --localTs node_modules/typescript/lib types" 59 | }, 60 | "dependencies": { 61 | "cordova": "^9.0.0", 62 | "gists": "^2.0.0" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ionic-example/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { TestBed, async } from '@angular/core/testing'; 3 | 4 | import { Platform } from '@ionic/angular'; 5 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 6 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 7 | 8 | import { AppComponent } from './app.component'; 9 | 10 | describe('AppComponent', () => { 11 | 12 | let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; 13 | 14 | beforeEach(async(() => { 15 | statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); 16 | splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); 17 | platformReadySpy = Promise.resolve(); 18 | platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy }); 19 | 20 | TestBed.configureTestingModule({ 21 | declarations: [AppComponent], 22 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 23 | providers: [ 24 | { provide: StatusBar, useValue: statusBarSpy }, 25 | { provide: SplashScreen, useValue: splashScreenSpy }, 26 | { provide: Platform, useValue: platformSpy }, 27 | ], 28 | }).compileComponents(); 29 | })); 30 | 31 | it('should create the app', () => { 32 | const fixture = TestBed.createComponent(AppComponent); 33 | const app = fixture.debugElement.componentInstance; 34 | expect(app).toBeTruthy(); 35 | }); 36 | 37 | it('should initialize the app', async () => { 38 | TestBed.createComponent(AppComponent); 39 | expect(platformSpy.ready).toHaveBeenCalled(); 40 | await platformReadySpy; 41 | expect(statusBarSpy.styleDefault).toHaveBeenCalled(); 42 | expect(splashScreenSpy.hide).toHaveBeenCalled(); 43 | }); 44 | 45 | // TODO: add more tests! 46 | 47 | }); 48 | -------------------------------------------------------------------------------- /android/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /ionic-example/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": [ 4 | "codelyzer" 5 | ], 6 | "rules": { 7 | "array-type": false, 8 | "arrow-parens": false, 9 | "deprecation": { 10 | "severity": "warn" 11 | }, 12 | "import-blacklist": [ 13 | true, 14 | "rxjs/Rx" 15 | ], 16 | "interface-name": false, 17 | "max-classes-per-file": false, 18 | "max-line-length": [ 19 | true, 20 | 140 21 | ], 22 | "member-access": false, 23 | "member-ordering": [ 24 | true, 25 | { 26 | "order": [ 27 | "static-field", 28 | "instance-field", 29 | "static-method", 30 | "instance-method" 31 | ] 32 | } 33 | ], 34 | "no-consecutive-blank-lines": false, 35 | "no-console": [ 36 | true, 37 | "debug", 38 | "info", 39 | "time", 40 | "timeEnd", 41 | "trace" 42 | ], 43 | "no-empty": false, 44 | "no-inferrable-types": [ 45 | true, 46 | "ignore-params" 47 | ], 48 | "no-non-null-assertion": true, 49 | "no-redundant-jsdoc": true, 50 | "no-switch-case-fall-through": true, 51 | "no-use-before-declare": true, 52 | "no-var-requires": false, 53 | "object-literal-key-quotes": [ 54 | true, 55 | "as-needed" 56 | ], 57 | "object-literal-sort-keys": false, 58 | "ordered-imports": false, 59 | "quotemark": [ 60 | true, 61 | "single" 62 | ], 63 | "trailing-comma": false, 64 | "no-output-on-prefix": true, 65 | "no-inputs-metadata-property": true, 66 | "no-host-metadata-property": true, 67 | "no-input-rename": true, 68 | "no-output-rename": true, 69 | "use-lifecycle-interface": true, 70 | "use-pipe-transform-interface": true, 71 | "one-variable-per-declaration": false, 72 | "component-class-suffix": [true, "Page", "Component"], 73 | "directive-class-suffix": true, 74 | "directive-selector": [ 75 | true, 76 | "attribute", 77 | "app", 78 | "camelCase" 79 | ], 80 | "component-selector": [ 81 | true, 82 | "element", 83 | "app", 84 | "page", 85 | "kebab-case" 86 | ] 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | Cordova NativeView Plugin 7 | 8 | Start or Back to a UIViewController(ios)/Activity(Android) 9 | relative to your cordova app 10 | 11 | MIT 12 | cordova,activity,UIViewController,back 13 | https://github.com/mfdeveloper/cordova-plugin-nativeview.git 14 | https://github.com/mfdeveloper/cordova-plugin-nativeview/issues 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /ionic-example/src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/theming/ 3 | 4 | /** Ionic CSS Variables **/ 5 | :root { 6 | /** primary **/ 7 | --ion-color-primary: #3880ff; 8 | --ion-color-primary-rgb: 56, 128, 255; 9 | --ion-color-primary-contrast: #ffffff; 10 | --ion-color-primary-contrast-rgb: 255, 255, 255; 11 | --ion-color-primary-shade: #3171e0; 12 | --ion-color-primary-tint: #4c8dff; 13 | 14 | /** secondary **/ 15 | --ion-color-secondary: #0cd1e8; 16 | --ion-color-secondary-rgb: 12, 209, 232; 17 | --ion-color-secondary-contrast: #ffffff; 18 | --ion-color-secondary-contrast-rgb: 255, 255, 255; 19 | --ion-color-secondary-shade: #0bb8cc; 20 | --ion-color-secondary-tint: #24d6ea; 21 | 22 | /** tertiary **/ 23 | --ion-color-tertiary: #7044ff; 24 | --ion-color-tertiary-rgb: 112, 68, 255; 25 | --ion-color-tertiary-contrast: #ffffff; 26 | --ion-color-tertiary-contrast-rgb: 255, 255, 255; 27 | --ion-color-tertiary-shade: #633ce0; 28 | --ion-color-tertiary-tint: #7e57ff; 29 | 30 | /** success **/ 31 | --ion-color-success: #10dc60; 32 | --ion-color-success-rgb: 16, 220, 96; 33 | --ion-color-success-contrast: #ffffff; 34 | --ion-color-success-contrast-rgb: 255, 255, 255; 35 | --ion-color-success-shade: #0ec254; 36 | --ion-color-success-tint: #28e070; 37 | 38 | /** warning **/ 39 | --ion-color-warning: #ffce00; 40 | --ion-color-warning-rgb: 255, 206, 0; 41 | --ion-color-warning-contrast: #ffffff; 42 | --ion-color-warning-contrast-rgb: 255, 255, 255; 43 | --ion-color-warning-shade: #e0b500; 44 | --ion-color-warning-tint: #ffd31a; 45 | 46 | /** danger **/ 47 | --ion-color-danger: #f04141; 48 | --ion-color-danger-rgb: 245, 61, 61; 49 | --ion-color-danger-contrast: #ffffff; 50 | --ion-color-danger-contrast-rgb: 255, 255, 255; 51 | --ion-color-danger-shade: #d33939; 52 | --ion-color-danger-tint: #f25454; 53 | 54 | /** dark **/ 55 | --ion-color-dark: #222428; 56 | --ion-color-dark-rgb: 34, 34, 34; 57 | --ion-color-dark-contrast: #ffffff; 58 | --ion-color-dark-contrast-rgb: 255, 255, 255; 59 | --ion-color-dark-shade: #1e2023; 60 | --ion-color-dark-tint: #383a3e; 61 | 62 | /** medium **/ 63 | --ion-color-medium: #989aa2; 64 | --ion-color-medium-rgb: 152, 154, 162; 65 | --ion-color-medium-contrast: #ffffff; 66 | --ion-color-medium-contrast-rgb: 255, 255, 255; 67 | --ion-color-medium-shade: #86888f; 68 | --ion-color-medium-tint: #a2a4ab; 69 | 70 | /** light **/ 71 | --ion-color-light: #f4f5f8; 72 | --ion-color-light-rgb: 244, 244, 244; 73 | --ion-color-light-contrast: #000000; 74 | --ion-color-light-contrast-rgb: 0, 0, 0; 75 | --ion-color-light-shade: #d7d8da; 76 | --ion-color-light-tint: #f5f6f9; 77 | } 78 | -------------------------------------------------------------------------------- /ionic-example/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags.ts'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | import './zone-flags.ts'; 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | 61 | import 'zone.js/dist/zone'; // Included with Angular CLI. 62 | 63 | 64 | /*************************************************************************************************** 65 | * APPLICATION IMPORTS 66 | */ 67 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md 66 | 67 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 68 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 69 | 70 | # User-specific stuff 71 | .idea/**/workspace.xml 72 | .idea/**/tasks.xml 73 | .idea/**/usage.statistics.xml 74 | .idea/**/dictionaries 75 | .idea/**/shelf 76 | 77 | # Generated files 78 | .idea/**/contentModel.xml 79 | 80 | # Sensitive or high-churn files 81 | .idea/**/dataSources/ 82 | .idea/**/dataSources.ids 83 | .idea/**/dataSources.local.xml 84 | .idea/**/sqlDataSources.xml 85 | .idea/**/dynamic.xml 86 | .idea/**/uiDesigner.xml 87 | .idea/**/dbnavigator.xml 88 | 89 | # Gradle 90 | .idea/**/gradle.xml 91 | .idea/**/libraries 92 | 93 | # Gradle and Maven with auto-import 94 | # When using Gradle or Maven with auto-import, you should exclude module files, 95 | # since they will be recreated, and may cause churn. Uncomment if using 96 | # auto-import. 97 | # .idea/modules.xml 98 | # .idea/*.iml 99 | # .idea/modules 100 | 101 | # CMake 102 | cmake-build-*/ 103 | 104 | # Mongo Explorer plugin 105 | .idea/**/mongoSettings.xml 106 | 107 | # File-based project format 108 | *.iws 109 | 110 | # IntelliJ 111 | out/ 112 | 113 | # mpeltonen/sbt-idea plugin 114 | .idea_modules/ 115 | 116 | # JIRA plugin 117 | atlassian-ide-plugin.xml 118 | 119 | # Cursive Clojure plugin 120 | .idea/replstate.xml 121 | 122 | # Crashlytics plugin (for Android Studio and IntelliJ) 123 | com_crashlytics_export_strings.xml 124 | crashlytics.properties 125 | crashlytics-build.properties 126 | fabric.properties 127 | 128 | # Editor-based Rest Client 129 | .idea/httpRequests 130 | 131 | # Android studio 3.1+ serialized cache file 132 | .idea/caches/build_file_checksums.ser 133 | -------------------------------------------------------------------------------- /ionic-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionic-example", 3 | "version": "0.0.1", 4 | "author": "Ionic Framework", 5 | "homepage": "https://ionicframework.com/", 6 | "engines": { 7 | "ionic": ">=5.2.5", 8 | "cordova": ">=7.0.0", 9 | "native-run": ">=0.2.8" 10 | }, 11 | "scripts": { 12 | "ng": "ng", 13 | "start": "ng serve", 14 | "build": "ng build", 15 | "test": "ng test", 16 | "lint": "ng lint", 17 | "e2e": "ng e2e" 18 | }, 19 | "private": true, 20 | "dependencies": { 21 | "@angular/common": "~8.1.2", 22 | "@angular/compiler": "~8.1.2", 23 | "@angular/core": "~8.1.2", 24 | "@angular/forms": "~8.1.2", 25 | "@angular/platform-browser": "~8.1.2", 26 | "@angular/platform-browser-dynamic": "~8.1.2", 27 | "@angular/router": "~8.1.2", 28 | "@ionic-native/core": "^5.0.0", 29 | "@ionic-native/splash-screen": "^5.0.0", 30 | "@ionic-native/status-bar": "^5.0.0", 31 | "@ionic/angular": "^4.7.1", 32 | "cordova-android": "^7.0.0", 33 | "cordova-ios": "^4.5.5", 34 | "cordova-plugin-device": "^2.0.2", 35 | "cordova-plugin-ionic-keyboard": "^2.1.3", 36 | "cordova-plugin-ionic-webview": "^4.1.1", 37 | "cordova-plugin-nativeview": "git+https://github.com/mfdeveloper/cordova-plugin-nativeview.git#1.0.11", 38 | "cordova-plugin-splashscreen": "^5.0.2", 39 | "cordova-plugin-statusbar": "^2.4.2", 40 | "cordova-plugin-whitelist": "^1.3.3", 41 | "core-js": "^2.5.4", 42 | "es6-promise-plugin": "^4.2.2", 43 | "rxjs": "~6.5.1", 44 | "tslib": "^1.9.0", 45 | "zone.js": "~0.9.1" 46 | }, 47 | "devDependencies": { 48 | "@angular-devkit/architect": "~0.801.2", 49 | "@angular-devkit/build-angular": "~0.801.2", 50 | "@angular-devkit/core": "~8.1.2", 51 | "@angular-devkit/schematics": "~8.1.2", 52 | "@angular/cli": "~8.1.2", 53 | "@angular/compiler": "~8.1.2", 54 | "@angular/compiler-cli": "~8.1.2", 55 | "@angular/language-service": "~8.1.2", 56 | "@ionic/angular-toolkit": "~2.0.0", 57 | "@types/jasmine": "~3.3.8", 58 | "@types/jasminewd2": "~2.0.3", 59 | "@types/node": "~8.9.4", 60 | "codelyzer": "^5.0.0", 61 | "jasmine-core": "~3.4.0", 62 | "jasmine-spec-reporter": "~4.2.1", 63 | "karma": "~4.1.0", 64 | "karma-chrome-launcher": "~2.2.0", 65 | "karma-coverage-istanbul-reporter": "~2.0.1", 66 | "karma-jasmine": "~2.0.1", 67 | "karma-jasmine-html-reporter": "^1.4.0", 68 | "protractor": "~5.4.0", 69 | "ts-node": "~7.0.0", 70 | "tslint": "~5.15.0", 71 | "typescript": "~3.4.3", 72 | "kind-of": ">=6.0.3", 73 | "minimist": ">=1.2.2", 74 | "acorn": ">=6.4.1", 75 | "handlebars": ">=4.3.0", 76 | "serialize-javascript": ">=3.1.0" 77 | }, 78 | "description": "An Ionic project", 79 | "cordova": { 80 | "plugins": { 81 | "cordova-plugin-whitelist": {}, 82 | "cordova-plugin-statusbar": {}, 83 | "cordova-plugin-device": {}, 84 | "cordova-plugin-splashscreen": {}, 85 | "cordova-plugin-ionic-webview": { 86 | "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" 87 | }, 88 | "cordova-plugin-ionic-keyboard": {}, 89 | "cordova-plugin-nativeview": {} 90 | }, 91 | "platforms": [ 92 | "android", 93 | "ios" 94 | ] 95 | } 96 | } -------------------------------------------------------------------------------- /types/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | /** 4 | * Use `dtslint` to verify the syntax of this 5 | * typescript declaration file 6 | * @see https://github.com/Microsoft/dtslint 7 | */ 8 | 9 | declare global { 10 | interface CordovaPlugins { 11 | NativeView: NativeView 12 | } 13 | } 14 | 15 | export interface ResultView { 16 | success: boolean; 17 | name?: string; 18 | message?: string; 19 | uri?: string; 20 | [key: string]: any; 21 | } 22 | 23 | export interface ResultAppInstalled extends ResultView { 24 | packageName?: string; 25 | applicationInfo?: string; 26 | activityName?: string; 27 | } 28 | 29 | export interface NativeParams { 30 | package?: string; 31 | packageName?: string; 32 | packageApp?: string; 33 | className?: string; 34 | uri?: string; 35 | storyboardName?: string; 36 | viewControllerName?: string; 37 | params?: string; 38 | } 39 | 40 | export interface NativeMarketParams extends NativeParams { 41 | marketId?: string; 42 | } 43 | 44 | export interface NativeView { 45 | 46 | /** 47 | * Shows the native view. 48 | * 49 | * Define the `packageOrClass` param to a package (Android) or a 50 | * storyboard/classname (IOS) 51 | * 52 | * ```ts 53 | * 54 | * //Android 55 | * cordova.plugins.NativeView.show('com.mycompany', 'MyActivity') 56 | * .then(() => { 57 | * // Do something 58 | * }); 59 | * 60 | * //IOS 61 | * cordova.plugins.NativeView.show('MyStoryboard', 'MyUIViewController') 62 | * .then(() => { 63 | * // Do something 64 | * }); 65 | * 66 | * //OR Back to previous View (IOS only) 67 | * cordova.plugins.NativeView.show().then(() => { 68 | * // Do something 69 | * }); 70 | * 71 | * ``` 72 | * 73 | * @param {NativeParams|string} packageOrClass Package or class name of view to open 74 | * @param {string} className Class name of view to open 75 | * @param {any} [extraParams] [Optional] Params to send to a Native view that will be opened 76 | * @param {Function} [success] [Optional] Callback when success, if you don't want use promise "then()" 77 | * @param {Function} [error] [Optional] Callback when error happens, if you don't want use promise "catch()" 78 | */ 79 | show(packageOrClass: NativeParams | string, className?: string, extraParams?: any, success?: Function, error?: Function): Promise; 80 | 81 | /** 82 | * Check if a specific app is installed 83 | * 84 | * @param {NativeParams} config 85 | * @param {Function} [success] Callback when success. Use `.then()` Promise method, instead 86 | * @param {Function} [error] Callback callbed when an error happens. Use `.catch()` Promise method, instead 87 | * @returns {Promise} Returns data information about the installed app 88 | * @memberof NativeView 89 | */ 90 | checkIfAppInstalled(config: NativeParams, success?: Function, error?: Function): Promise; 91 | 92 | /** 93 | * Shows a store/market fo install a specific app 94 | * 95 | * @param {NativeMarketParams} config Native package and/or marketId to show in Google Play/Apple Store 96 | * @param {Function} [success] Callback when success. Use `.then()` Promise method, instead 97 | * @param {Function} [error] Callback callbed when an error happens. Use `.catch()` Promise method, instead 98 | * @returns {Promise} 99 | * @memberof NativeView 100 | */ 101 | showMarket(config: NativeMarketParams, success?: Function, error?: Function): Promise; 102 | 103 | /** 104 | * ### ANDROID ONLY 105 | * 106 | * Get the **Android** current build variant FLAVOR 107 | * This is great if you change the FLAVOR in compile time 108 | * 109 | * @param {{catchError?: boolean}} config `config.catchError` True, if you wish catch a JSON with error information 110 | * @param {Function} [success] Callback when success. Use `.then()` Promise method, instead 111 | * @param {Function} [error] Callback callbed when an error happens. Use `.catch()` Promise method, instead 112 | * @returns {Promise} Returns a current FLAVOR string 113 | * @memberof NativeView 114 | */ 115 | getBuildVariant(config: {catchError?: boolean}, success?: Function, error?: Function): Promise; 116 | } -------------------------------------------------------------------------------- /cordova-plugin-nativeview.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint cordova-plugin-nativeview.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "cordova-plugin-nativeview" 19 | s.version = "1.0.11" 20 | s.summary = "Start or Back to a native screen/page from app or other app" 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = <<-DESC 28 | Start or Back to a UIViewController(ios)/Activity(Android) 29 | relative to you cordova app or open other screen/page from other app. You can 30 | start another app too (by package, uri scheme...) 31 | DESC 32 | 33 | s.homepage = "https://github.com/mfdeveloper/cordova-plugin-nativeview" 34 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 35 | 36 | 37 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 38 | # 39 | # Licensing your code is important. See http://choosealicense.com for more info. 40 | # CocoaPods will detect a license file if there is a named LICENSE* 41 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 42 | # 43 | 44 | s.license = "MIT" 45 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 46 | 47 | 48 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 49 | # 50 | # Specify the authors of the library, with email addresses. Email addresses 51 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 52 | # accepts just a name if you'd rather not provide an email address. 53 | # 54 | # Specify a social_media_url where others can refer to, for example a twitter 55 | # profile URL. 56 | # 57 | 58 | s.author = { "Michel Felipe" => "mfelipeof@gmail.com" } 59 | # Or just: s.author = "" 60 | # s.authors = { "" => "mfelipeof@gmail.com" } 61 | # s.social_media_url = "http://twitter.com/" 62 | 63 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 64 | # 65 | # If this Pod runs only on iOS or OS X, then specify the platform and 66 | # the deployment target. You can optionally include the target after the platform. 67 | # 68 | 69 | # s.platform = :ios 70 | s.platform = :ios, "8.0" 71 | 72 | # When using multiple platforms 73 | # s.ios.deployment_target = "5.0" 74 | # s.osx.deployment_target = "10.7" 75 | # s.watchos.deployment_target = "2.0" 76 | # s.tvos.deployment_target = "9.0" 77 | 78 | 79 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 80 | # 81 | # Specify the location from where the source should be retrieved. 82 | # Supports git, hg, bzr, svn and HTTP. 83 | # 84 | 85 | s.source = { :git => "https://github.com/mfdeveloper/cordova-plugin-nativeview.git", :tag => "#{s.version}" } 86 | 87 | 88 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 89 | # 90 | # CocoaPods is smart about how it includes source code. For source files 91 | # giving a folder will include any swift, h, m, mm, c & cpp files. 92 | # For header files it will include any header in the folder. 93 | # Not including the public_header_files will make all headers public. 94 | # 95 | 96 | s.source_files = "src/ios/*.{h,m}" 97 | #s.exclude_files = "Classes/Exclude" 98 | 99 | # s.public_header_files = "Classes/**/*.h" 100 | 101 | 102 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 103 | # 104 | # A list of resources included with the Pod. These are copied into the 105 | # target bundle with a build phase script. Anything else will be cleaned. 106 | # You can preserve files from being cleaned, please don't preserve 107 | # non-essential files like tests, examples and documentation. 108 | # 109 | 110 | # s.resource = "icon.png" 111 | # s.resources = "Resources/*.png" 112 | 113 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 114 | 115 | 116 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 117 | # 118 | # Link your library with frameworks, or libraries. Libraries do not include 119 | # the lib prefix of their name. 120 | # 121 | 122 | # s.framework = "SomeFramework" 123 | # s.frameworks = "SomeFramework", "AnotherFramework" 124 | 125 | # s.library = "iconv" 126 | # s.libraries = "iconv", "xml2" 127 | 128 | 129 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 130 | # 131 | # If your library depends on compiler flags you can set them in the xcconfig hash 132 | # where they will only apply to your library. If you depend on other Podspecs 133 | # you can include multiple dependencies to ensure it works. 134 | 135 | # s.requires_arc = true 136 | 137 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 138 | # s.dependency "JSONKit", "~> 1.4" 139 | s.dependency "Cordova", ">= 4.3.0" 140 | 141 | end 142 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /ionic-example/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "defaultProject": "app", 5 | "newProjectRoot": "projects", 6 | "projects": { 7 | "app": { 8 | "root": "", 9 | "sourceRoot": "src", 10 | "projectType": "application", 11 | "prefix": "app", 12 | "schematics": {}, 13 | "architect": { 14 | "build": { 15 | "builder": "@angular-devkit/build-angular:browser", 16 | "options": { 17 | "outputPath": "www", 18 | "index": "src/index.html", 19 | "main": "src/main.ts", 20 | "polyfills": "src/polyfills.ts", 21 | "tsConfig": "tsconfig.app.json", 22 | "assets": [ 23 | { 24 | "glob": "**/*", 25 | "input": "src/assets", 26 | "output": "assets" 27 | }, 28 | { 29 | "glob": "**/*.svg", 30 | "input": "node_modules/ionicons/dist/ionicons/svg", 31 | "output": "./svg" 32 | } 33 | ], 34 | "styles": [ 35 | { 36 | "input": "src/theme/variables.scss" 37 | }, 38 | { 39 | "input": "src/global.scss" 40 | } 41 | ], 42 | "scripts": [] 43 | }, 44 | "configurations": { 45 | "production": { 46 | "fileReplacements": [ 47 | { 48 | "replace": "src/environments/environment.ts", 49 | "with": "src/environments/environment.prod.ts" 50 | } 51 | ], 52 | "optimization": true, 53 | "outputHashing": "all", 54 | "sourceMap": false, 55 | "extractCss": true, 56 | "namedChunks": false, 57 | "aot": true, 58 | "extractLicenses": true, 59 | "vendorChunk": false, 60 | "buildOptimizer": true, 61 | "budgets": [ 62 | { 63 | "type": "initial", 64 | "maximumWarning": "2mb", 65 | "maximumError": "5mb" 66 | } 67 | ] 68 | }, 69 | "ci": { 70 | "progress": false 71 | } 72 | } 73 | }, 74 | "serve": { 75 | "builder": "@angular-devkit/build-angular:dev-server", 76 | "options": { 77 | "browserTarget": "app:build" 78 | }, 79 | "configurations": { 80 | "production": { 81 | "browserTarget": "app:build:production" 82 | }, 83 | "ci": { 84 | "progress": false 85 | } 86 | } 87 | }, 88 | "extract-i18n": { 89 | "builder": "@angular-devkit/build-angular:extract-i18n", 90 | "options": { 91 | "browserTarget": "app:build" 92 | } 93 | }, 94 | "test": { 95 | "builder": "@angular-devkit/build-angular:karma", 96 | "options": { 97 | "main": "src/test.ts", 98 | "polyfills": "src/polyfills.ts", 99 | "tsConfig": "tsconfig.spec.json", 100 | "karmaConfig": "karma.conf.js", 101 | "styles": [], 102 | "scripts": [], 103 | "assets": [ 104 | { 105 | "glob": "favicon.ico", 106 | "input": "src/", 107 | "output": "/" 108 | }, 109 | { 110 | "glob": "**/*", 111 | "input": "src/assets", 112 | "output": "/assets" 113 | } 114 | ] 115 | }, 116 | "configurations": { 117 | "ci": { 118 | "progress": false, 119 | "watch": false 120 | } 121 | } 122 | }, 123 | "lint": { 124 | "builder": "@angular-devkit/build-angular:tslint", 125 | "options": { 126 | "tsConfig": [ 127 | "tsconfig.app.json", 128 | "tsconfig.spec.json", 129 | "e2e/tsconfig.json" 130 | ], 131 | "exclude": ["**/node_modules/**"] 132 | } 133 | }, 134 | "e2e": { 135 | "builder": "@angular-devkit/build-angular:protractor", 136 | "options": { 137 | "protractorConfig": "e2e/protractor.conf.js", 138 | "devServerTarget": "app:serve" 139 | }, 140 | "configurations": { 141 | "production": { 142 | "devServerTarget": "app:serve:production" 143 | }, 144 | "ci": { 145 | "devServerTarget": "app:serve:ci" 146 | } 147 | } 148 | }, 149 | "ionic-cordova-build": { 150 | "builder": "@ionic/angular-toolkit:cordova-build", 151 | "options": { 152 | "browserTarget": "app:build" 153 | }, 154 | "configurations": { 155 | "production": { 156 | "browserTarget": "app:build:production" 157 | } 158 | } 159 | }, 160 | "ionic-cordova-serve": { 161 | "builder": "@ionic/angular-toolkit:cordova-serve", 162 | "options": { 163 | "cordovaBuildTarget": "app:ionic-cordova-build", 164 | "devServerTarget": "app:serve" 165 | }, 166 | "configurations": { 167 | "production": { 168 | "cordovaBuildTarget": "app:ionic-cordova-build:production", 169 | "devServerTarget": "app:serve:production" 170 | } 171 | } 172 | } 173 | } 174 | } 175 | }, 176 | "cli": { 177 | "defaultCollection": "@ionic/angular-toolkit" 178 | }, 179 | "schematics": { 180 | "@ionic/angular-toolkit:component": { 181 | "styleext": "scss" 182 | }, 183 | "@ionic/angular-toolkit:page": { 184 | "styleext": "scss" 185 | } 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /ionic-example/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | MyApp 4 | An awesome Ionic/Cordova app. 5 | Ionic Framework Team 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [](https://badge.fury.io/js/cordova-plugin-nativeview) 2 | [](https://jitpack.io/#mfdeveloper/cordova-plugin-nativeview) 3 | 4 | --- 5 | title: NativeView 6 | description: Starts native view or another app, from a cordova app. 7 | --- 8 | 9 | # cordova-plugin-nativeview 10 | 11 | Start an UIViewController(_IOS_) or Activity(_Android_) relative to your cordova app, or an external app (based in [cordova plugin startapp](https://github.com/mfdeveloper/com.lampa.startapp) cordova plugin) 12 | 13 | You can use this in a standalone project (basic cordova project), or into an existing native _Android/IOS_ application, like described in [Embed Cordova in native apps](https://cordova.apache.org/docs/en/latest/guide/hybrid/webviews/index.html) 14 | 15 | > **OBS:** If you wish just **EXIT** from cordova app or back to native view (Android only), use: `navigator['app'].exitApp()` 16 | 17 | ## Installation 18 | 19 | ```bash 20 | cordova plugin add cordova-plugin-nativeview --save 21 | 22 | # using IONIC 23 | ionic cordova plugin add cordova-plugin-nativeview --save 24 | ``` 25 | 26 | ### Extra: Native app (_Android/IOS_ native code) 27 | 28 | **ALL PLATFORMS** 29 | 30 | Make sure that `config.xml` file contains the `` tag below: 31 | 32 | ```xml 33 | 34 | 35 | 36 | 37 | ``` 38 | 39 | **IOS** 40 | 41 | * Copy the `config.xml` from your cordova project to root XCode project directory. 42 | * Install [cocoapods](https://cocoapods.org/) 43 | * Add this plugin like a [pod](https://guides.cocoapods.org/syntax/podfile.html) dependency: 44 | 45 | ```ruby 46 | # Objective-C version (Default) 47 | pod 'cordova-plugin-nativeview', '~> 1.0.7' 48 | 49 | # Swift version (needs update to latest Objective-c implementations) 50 | pod 'cordova-plugin-nativeview', :git => 'https://github.com/mfdeveloper/cordova-plugin-nativeview.git', :branch => 'swift' 51 | ``` 52 | 53 | **ANDROID** 54 | 55 | 56 | Add this code snippet below to your `build.gradle` file 57 | 58 | ```groovy 59 | allprojects { 60 | repositories { 61 | ... 62 | maven { url 'https://jitpack.io' } 63 | } 64 | } 65 | 66 | implementation ('com.github.mfdeveloper:cordova-plugin-nativeview:1.0.7') 67 | ``` 68 | > This dependency is added using [jitpack](https://jitpack.io) 69 | 70 | Or add, the `NativeView` class directly to your android project: 71 | 72 | * From your cordova project: 73 | 74 | - Copy the content off `platforms/android/assets/www` folder to your android project (usually, `app/src/main/assets`). 75 | Or create a **gradle** task to do this. 76 | - Copy the `config.xml` to `src/main/res/xml` android project folder. 77 | 78 | * Clone this repo, and copy the class: `src/android/NativeView.java` to your Android project 79 | 80 | * Or create a `.jar` or a `.aar` that contains this class, and import like a [Android module dependency](https://developer.android.com/studio/projects/android-library.html#AddDependency) 81 | 82 | * Verify if the code snippet below is present in your `AndroidManifest.xml`. This is required to open a specific Activity from a [Intent](https://developer.android.com/reference/android/content/Intent.html) (using **[package + activityName]**) 83 | 84 | ```xml 85 | 86 | 87 | 88 | 89 | 90 | 91 | ``` 92 | > If this filter not exists in `AndroidManifest.xml`, you will get this error: [No Activity found to handle Intent splash screen](https://stackoverflow.com/questions/15614561/android-content-activitynotfoundexception-no-activity-found-to-handle-intent-sp) 93 | 94 | * Build/Run your android project! 95 | 96 | ## Supported Platforms 97 | 98 | -  Android 99 | -  iOS 100 | 101 | ## Methods 102 | 103 | ### NativeView.show(packageOrClassName: string, className: string) 104 | 105 | OR 106 | 107 | ### NativeView.show(params: object) 108 | 109 | > Shows a native view. 110 | 111 | 112 | ### ANDROID 113 | 114 | ```js 115 | 116 | document.addEventListener("deviceready", function() { 117 | // pass a package name and a activity by params 118 | cordova.plugins.NativeView.show('com.mycompany', 'MyActivity') 119 | .then(function() { 120 | 121 | /** 122 | * Do something when open the activity. 123 | * This code here will be executed in paralell, 124 | * not after open. 125 | */ 126 | }).catch(function(error) { 127 | 128 | /** 129 | * error.success => Will be "false" 130 | * error.name => Exception type from the captured error 131 | * error.message => A exception message 132 | */ 133 | }); 134 | 135 | // Preferably, pass the Package and Activity in a json 136 | cordova.plugins.NativeView.show({ 137 | packageName: 'com.mycompany', 138 | className: 'MyActivity', 139 | }); 140 | 141 | }, false); 142 | 143 | ``` 144 | ### IOS 145 | 146 | 147 | - Pass `Storyboard` name and `storyboard id` 148 | 149 | ```js 150 | document.addEventListener("deviceready", function() { 151 | 152 | /* 153 | * The first param is a storyboard name, and 154 | * the second param is a storyboardId 155 | * (conventionally the same name of the ViewController class name) 156 | */ 157 | cordova.plugins.NativeView.show('MyStoryboard', 'MyUIViewController') 158 | .then(function() { 159 | 160 | /** 161 | * Do something when open the activity. 162 | * This code here will be executed in paralell, 163 | * not after open. 164 | */ 165 | }); 166 | 167 | // Preferably, pass the ViewController and Storyboard in a json 168 | cordova.plugins.NativeView.show({ 169 | storyboardName: 'MyStoryboard', 170 | viewControllerName: 'MyUIViewController' 171 | }); 172 | 173 | }, false); 174 | 175 | ``` 176 | 177 | - Pass only the `ViewController` class/xib name 178 | 179 | ```js 180 | /* 181 | * Or, pass only the UIViewController name, if you don't 182 | * use storyboards in your project. This plugin try instantiate 183 | * from a ".xib" file. If not exists, try instantiate just by 184 | * UIViewController class. 185 | * 186 | * By convention, your ViewController class/xib needs contains 'Controller' 187 | * string in any part of the name 188 | * . 189 | */ 190 | cordova.plugins.NativeView.show('MyUIViewController'); 191 | 192 | // Preferably, pass the ViewController in a json 193 | cordova.plugins.NativeView.show({ 194 | viewControllerName: 'MyUIViewController' 195 | }); 196 | ``` 197 | 198 | - Pass only the `Storyboard` name 199 | 200 | ```js 201 | /* 202 | * Or, pass only the Storyboard name. If you don't pass a 203 | * ViewController class name in second param, the 204 | * "rootViewController" of your storyboard will be 205 | * instantiated. 206 | * 207 | * By convention, your Storyboard name needs contains 'Storyboard' 208 | * string in any part of the name 209 | */ 210 | cordova.plugins.NativeView.show('MyStorboard'); 211 | 212 | // Preferably, pass the Storyboard in a json 213 | cordova.plugins.NativeView.show({ 214 | storyboardName: 'MyStorboard' 215 | }); 216 | ```` 217 | 218 | ### NativeView.checkIfAppInstalled(uri: string) 219 | 220 | OR 221 | 222 | ### NativeView.checkIfAppInstalled(params: { uri: string }) 223 | 224 | > Verify if another app that responds to a `uri` is installed on device. 225 | 226 | ```js 227 | 228 | cordova.plugins.NativeView.checkIfAppInstalled('another-app://custom-host') 229 | .then(function() { 230 | console.log('The app is INSTALLED!'); 231 | }).catch(function(error) { 232 | console.log("The app is NOT INSTALLED!"); 233 | throw error; 234 | }); 235 | 236 | // Preferably, pass the uri in a json 237 | cordova.plugins.NativeView.show({ 238 | uri: 'another-app://custom-host' 239 | }); 240 | ``` 241 | 242 | ### NativeView.showMarket(marketId: string) 243 | 244 | OR 245 | 246 | ### NativeView.showMarket(params: { marketId: string }) 247 | 248 | > Open the store (Apple Store/Google Play) app installed in your device, or in a browser. 249 | 250 | ### ANDROID 251 | 252 | ```js 253 | 254 | // Pass a app package on Android (found this on Google Play) 255 | cordova.plugins.NativeView.showMarket('my.company.other.app'); 256 | 257 | // Preferably, pass the marketId in a json 258 | cordova.plugins.NativeView.show({ 259 | marketId: 'my.company.other.app' 260 | }); 261 | ``` 262 | 263 | ### IOS 264 | 265 | ```js 266 | 267 | // Pass a app id from the Apple Store 268 | cordova.plugins.NativeView.showMarket('idxyz1?mt=x'); 269 | 270 | // Preferably, pass the marketId in a json 271 | cordova.plugins.NativeView.showMarket({ 272 | marketId: 'idxyz1?mt=x' 273 | }); 274 | ``` 275 | 276 | ### NativeView.getBuildVariant(params: { catchError: boolean }) 277 | 278 | > Get the current Android build variant configured in 279 | 280 | ### ANDROID (ONLY) 281 | 282 | ```js 283 | 284 | /* 285 | * Pass the param "catchError", and use the `catch()` method to verify an 286 | * error (if happens) 287 | * 288 | * Otherwise, this method will return the variant like a string, 289 | * or null if not found. 290 | * 291 | * This is useful if you need show a NativeView by environment 292 | */ 293 | cordova.plugins.NativeView.getBuildVariant({ 294 | catchError: true 295 | }).then(function(value) { 296 | console.log('My environment is: ' + value); 297 | }).catch(function(error) { 298 | if (!error.success && error.message) { 299 | console.log(error.message); 300 | } 301 | }); 302 | 303 | /* Optionally, don't pass any parameter and get the Build Variant 304 | * value, or NULL 305 | */ 306 | cordova.plugins.NativeView.getBuildVariant() 307 | .then(function(value) { 308 | console.log('My environment is: ' + value); 309 | }); 310 | ``` 311 | 312 | ### IONIC 313 | 314 | Replace `document.addEventListener` event to `this.platform.ready().then(...)` service method. See [IONIC Platform documentation](https://ionicframework.com/docs/api/platform/Platform/) 315 | 316 | ## License 317 | 318 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details 319 | 320 | ## TODO 321 | 322 | - [x] Better catch IOS exception from JS 323 | - [ ] Update `Swift` implementation 324 | - [ ] Add cordova integration tests 325 | -------------------------------------------------------------------------------- /src/ios/CDVNativeView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CDVNativeView.m 3 | // 4 | // Created by Michel Felipe on 05/09/17. 5 | // 6 | // 7 | 8 | #import "CDVNativeView.h" 9 | #import 10 | 11 | @interface CDVNativeView (hidden) 12 | 13 | -(UIViewController *) instantiateViewControllerWithName: (NSString*) name; 14 | -(UIViewController *) tryInstantiateViewWithName: (NSString*) name; 15 | 16 | @end 17 | 18 | @implementation CDVNativeView 19 | 20 | - (instancetype)init 21 | { 22 | self = [super init]; 23 | if (self) { 24 | self.resultExceptions = @{ 25 | @"IoException": ^{ 26 | return CDVCommandStatus_IO_EXCEPTION; 27 | }, 28 | @"NotFoundException": ^{ 29 | return CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION; 30 | }, 31 | @"ParamInvalidException": ^{ 32 | return CDVCommandStatus_ERROR; 33 | }, 34 | @"InstantiationException": ^{ 35 | return CDVCommandStatus_INSTANTIATION_EXCEPTION; 36 | }, 37 | @"NoResultException": ^{ 38 | return CDVCommandStatus_NO_RESULT; 39 | }, 40 | @"ParamsTypeException": ^{ 41 | return CDVCommandStatus_INVALID_ACTION; 42 | } 43 | }; 44 | } 45 | return self; 46 | } 47 | - (void)show:(CDVInvokedUrlCommand*)command { 48 | 49 | CDVPluginResult *pluginResult; 50 | 51 | @try { 52 | 53 | NSString *viewControllerName; 54 | NSString *storyboardName; 55 | NSString *uri; 56 | NSString *message; 57 | NSString *firstParam; 58 | 59 | NSMutableDictionary* config = [command.arguments objectAtIndex:0]; 60 | 61 | if ([config isKindOfClass:[NSMutableDictionary class]]) { 62 | 63 | viewControllerName = [config objectForKey:@"viewControllerName"]; 64 | storyboardName = [config objectForKey:@"storyboardName"]; 65 | uri = [config objectForKey:@"uri"]; 66 | 67 | } else if ([config isKindOfClass:[NSString class]]) { 68 | 69 | if ([command.arguments count] == 1) { 70 | 71 | firstParam = [command argumentAtIndex: 0]; 72 | 73 | if ([self isValidURI: firstParam]) { 74 | // Open app with valid uri name 75 | [self openAPP:firstParam withCommand: command]; 76 | 77 | } else if ([firstParam containsString:@"Storyboard"]) { 78 | // Init viewController from Storyboard with initial view Controller or user defined viewControllerName 79 | [self instantiateViewController:nil fromStoryboard:firstParam]; 80 | 81 | } else if ([firstParam containsString:@"Controller"]) { 82 | // Init viewController with or without xib 83 | [self instantiateViewController:firstParam]; 84 | 85 | } else { 86 | message = [[NSString alloc] initWithFormat:@"%@ invalid. Must contain a Storyboard / Controller / URI valid in name", firstParam]; 87 | @throw [[NSException alloc] initWithName:@"IoException" reason:message userInfo:nil]; 88 | } 89 | 90 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; 91 | return; 92 | 93 | }else if ([command.arguments count] == 2) { 94 | 95 | // first param is Storyboard 96 | storyboardName = [command argumentAtIndex: 0]; 97 | 98 | // second param is ViewController and/or storyboardId 99 | viewControllerName = [command argumentAtIndex: 1]; 100 | 101 | }else{ 102 | message = [[NSString alloc] initWithFormat:@"An UIViewController name or Storyboard name or URI valid name is required at least. Please, pass in the first param in JS, like this: 'NativeView.show('MyViewController') or NativeView.show('MyStoryboard') or NativeView.show('MyStoryboard', 'MyViewController') or NativeView.show('instagram://')"]; 103 | @throw [[NSException alloc] initWithName:@"NotFoundException" reason:message userInfo:nil]; 104 | } 105 | 106 | }else{ 107 | @throw [[NSException alloc] initWithName:@"ParamsTypeException" reason:@"The params of show() method needs be a string or a json" userInfo:nil]; 108 | } 109 | 110 | if ([self isValidURI: uri]) { 111 | // Open app with valid uri name 112 | [self openAPP:uri withCommand: command]; 113 | 114 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; 115 | } else if (viewControllerName != nil || storyboardName != nil) { 116 | // Init viewController from Storyboard with initial view Controlleror or user defined viewControllerName 117 | [self instantiateViewController:viewControllerName fromStoryboard:storyboardName]; 118 | 119 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; 120 | } 121 | 122 | } @catch (NSException *e) { 123 | NSLog(@"[%@]: %@", e.name, e.reason); 124 | 125 | typedef CDVCommandStatus (^CaseBlock)(void); 126 | 127 | CaseBlock c = self.resultExceptions[e.name]; 128 | 129 | CDVCommandStatus exceptionType = c ? c() : CDVCommandStatus_ERROR; 130 | NSDictionary* error = @{ 131 | @"success": @NO, 132 | @"name": e.name, 133 | @"message": e.reason 134 | }; 135 | 136 | pluginResult = [CDVPluginResult resultWithStatus:exceptionType messageAsDictionary:error]; 137 | } 138 | 139 | [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 140 | } 141 | 142 | - (void)showMarket:(CDVInvokedUrlCommand*)command { 143 | 144 | NSMutableDictionary* config = [command.arguments objectAtIndex:0]; 145 | 146 | dispatch_async(dispatch_get_main_queue(), ^{ 147 | 148 | CDVPluginResult *pluginResult; 149 | NSString *appId; 150 | 151 | if ([config isKindOfClass:[NSMutableDictionary class]]) { 152 | appId = [config objectForKey:@"marketId"]; 153 | }else if([config isKindOfClass:[NSString class]]) { 154 | appId = (NSString *) config; 155 | } 156 | 157 | if (appId && [appId isKindOfClass:[NSString class]] && [appId length] > 0) { 158 | NSString *url = [NSString stringWithFormat:@"itms://itunes.apple.com/app/%@", appId]; 159 | 160 | [self openAPP:url withCommand: command]; 161 | 162 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; 163 | } else { 164 | NSDictionary* error = @{ 165 | @"success": @NO, 166 | @"name": @"ParamInvalidException", 167 | @"message": @"Invalid application id: the parameter 'marketId' is invalid" 168 | }; 169 | 170 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_INVALID_ACTION messageAsDictionary:error]; 171 | } 172 | 173 | [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 174 | }); 175 | } 176 | 177 | - (void)checkIfAppInstalled:(CDVInvokedUrlCommand*)command { 178 | CDVPluginResult *pluginResult; 179 | NSString *uri; 180 | 181 | @try { 182 | NSMutableDictionary* config = [command.arguments objectAtIndex:0]; 183 | 184 | if ([config isKindOfClass:[NSMutableDictionary class]]) { 185 | uri = [config objectForKey:@"uri"]; 186 | 187 | if (uri == nil) { 188 | @throw [[NSException alloc] initWithName:@"ParamsTypeException" reason:@"The 'uri' key is required" userInfo:nil]; 189 | } 190 | }else if ([config isKindOfClass:[NSString class]]) { 191 | uri = (NSString *) config; 192 | }else{ 193 | @throw [[NSException alloc] initWithName:@"ParamsTypeException" reason:@"The params of checkIfAppInstalled() method needs be a string or a json" userInfo:nil]; 194 | } 195 | 196 | if (![self isValidURI: uri]) { 197 | NSString *message = [[NSString alloc] initWithFormat:@"uri param invalid: %@", uri]; 198 | NSDictionary* error = @{ 199 | @"success": @NO, 200 | @"name": @"ParamInvalidException", 201 | @"message": message 202 | }; 203 | 204 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:error]; 205 | } else { 206 | if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:uri]]) { 207 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:(true)]; 208 | } 209 | else { 210 | NSString *message = [[NSString alloc] initWithFormat:@"The app that responds to URI: %@ was not found", uri]; 211 | NSDictionary* error = @{ 212 | @"success": @NO, 213 | @"name": @"NotFoundException", 214 | @"message": message 215 | }; 216 | 217 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION messageAsDictionary:error]; 218 | } 219 | } 220 | } @catch (NSException *e) { 221 | NSLog(@"[%@]: %@", e.name, e.reason); 222 | 223 | typedef CDVCommandStatus (^CaseBlock)(void); 224 | 225 | CaseBlock c = self.resultExceptions[e.name]; 226 | 227 | CDVCommandStatus exceptionType = c ? c() : CDVCommandStatus_ERROR; 228 | NSDictionary* error = @{ 229 | @"success": @NO, 230 | @"name": e.name, 231 | @"message": e.reason 232 | }; 233 | pluginResult = [CDVPluginResult resultWithStatus:exceptionType messageAsDictionary:error]; 234 | } @finally { 235 | [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 236 | } 237 | 238 | [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId ]; 239 | } 240 | 241 | - (void) instantiateViewController:(NSString *)viewControllerName { 242 | 243 | NSString *message; 244 | 245 | if (viewControllerName && viewControllerName.length > 0) { 246 | 247 | UIViewController *destinyViewController = nil; 248 | 249 | // Call preInitializeViewControllerWithName if exists in self.viewController 250 | SEL selector = NSSelectorFromString(@"preInitializeViewControllerWithName:"); 251 | 252 | if ([self.viewController respondsToSelector:selector]) { 253 | 254 | SuppressPerformSelectorLeakWarning( 255 | destinyViewController = [self.viewController performSelector:selector withObject:viewControllerName]; 256 | ); 257 | } 258 | 259 | // if not performSelector, call automatically the viewController 260 | if (!destinyViewController) { 261 | @try { 262 | if ([[NSBundle mainBundle] pathForResource:viewControllerName ofType:@"nib"]) { 263 | // Initialize with nib/xib 264 | destinyViewController = [[UIViewController alloc] initWithNibName:viewControllerName bundle:nil]; 265 | } else { 266 | // Initialize without nib/xib 267 | Class viewController = NSClassFromString(viewControllerName); 268 | id anInstance = [[viewController alloc] init]; 269 | destinyViewController = anInstance; 270 | } 271 | } @catch(NSException *e) { 272 | message = [[NSString alloc] initWithFormat:@"%@ and/or its own xib does not exist. \nDetail: %@", viewControllerName, e.reason]; 273 | @throw [[NSException alloc] initWithName:@"NotFoundException" reason:message userInfo:nil]; 274 | } 275 | } 276 | 277 | // Call destinyViewController from current viewController 278 | if (self.viewController.navigationController) { 279 | [self.viewController.navigationController pushViewController:destinyViewController animated:YES]; 280 | } else { 281 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:destinyViewController]; 282 | self.viewController.view.window.rootViewController = nav; 283 | } 284 | 285 | } else { 286 | message = [[NSString alloc] initWithFormat:@"UIViewController with name %@ was not found", viewControllerName]; 287 | @throw [[NSException alloc] initWithName:@"ParamInvalidException" reason:message userInfo:nil]; 288 | } 289 | } 290 | 291 | - (void) instantiateViewController:(NSString *)viewControllerName fromStoryboard:(NSString *)storyboardName { 292 | 293 | NSString *message; 294 | 295 | if (storyboardName && storyboardName.length > 0) { 296 | 297 | UIViewController *destinyViewController = nil; 298 | 299 | // Call preInitializeViewControllerWithName:fromStoryBoardName if exists in self.viewController 300 | SEL selector = NSSelectorFromString(@"preInitializeViewControllerWithName:fromStoryBoardName:"); 301 | 302 | if ([self.viewController respondsToSelector:selector]) { 303 | 304 | SuppressPerformSelectorLeakWarning( 305 | destinyViewController = [self.viewController performSelector:selector withObject:viewControllerName withObject:storyboardName]; 306 | ); 307 | } 308 | 309 | // if not performSelector, call automatically the viewController from storyboard 310 | if (!destinyViewController) { 311 | // initialize a storyboard automatically from viewControllerName or default initialViewController property 312 | @try { 313 | UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:[NSBundle mainBundle]]; 314 | 315 | if (viewControllerName && viewControllerName.length > 0) { 316 | message = [[NSString alloc] initWithFormat:@"Identity -> Storyboard ID: %@ not found in storyboard %@", viewControllerName, storyboardName]; 317 | // if pass a viewControllerName, initializate the storyboard with viewControllerName initial 318 | destinyViewController = [storyboard instantiateViewControllerWithIdentifier:viewControllerName]; 319 | } else { 320 | message = [[NSString alloc] initWithFormat:@"Storyboard -> ViewController -> 'is Initial View Controller' not check in storyboard %@", storyboardName]; 321 | // if not pass a viewControllerName, initializate the storyboard with default inicialViewController property 322 | destinyViewController = [storyboard instantiateInitialViewController]; 323 | } 324 | } @catch (NSException *e) { 325 | NSString *detailMessage = [[NSString alloc] initWithFormat:@"%@ \nDetail: %@", message, e.reason]; 326 | @throw [[NSException alloc] initWithName:@"NotFoundException" reason:detailMessage userInfo:nil]; 327 | } 328 | } 329 | 330 | // Call destinyViewController from current viewController 331 | if (self.viewController.navigationController) { 332 | [self.viewController.navigationController pushViewController:destinyViewController animated:YES]; 333 | } else { 334 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:destinyViewController]; 335 | self.viewController.view.window.rootViewController = nav; 336 | } 337 | 338 | } else { 339 | message = [[NSString alloc] initWithFormat:@"Storyboard %@ was not found", storyboardName]; 340 | @throw [[NSException alloc] initWithName:@"ParamInvalidException" reason:message userInfo:nil]; 341 | } 342 | } 343 | 344 | - (bool) isValidURI:(NSString *)uri { 345 | if (uri != nil && [uri containsString:@"://"]) { // TODO: Replace for regular expression 346 | return true; 347 | } 348 | return false; 349 | } 350 | 351 | - (void) openAPP:(NSString *)uriValue withCommand:(CDVInvokedUrlCommand*) command { 352 | 353 | if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) { // ios >= 10 354 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:uriValue] options:@{} completionHandler:^(BOOL opened) { 355 | 356 | CDVPluginResult *pluginResult; 357 | 358 | if (!opened) { 359 | NSString* message = @"APP with uri %@ not found."; 360 | NSLog(message, uriValue); 361 | 362 | NSDictionary* error = @{ 363 | @"success": @NO, 364 | @"name": @"InstantiationException", 365 | @"message": [[NSString alloc] initWithFormat:message, uriValue] 366 | }; 367 | 368 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_INSTANTIATION_EXCEPTION messageAsDictionary:error]; 369 | } else { 370 | NSString* message = @"APP with uri %@ opened."; 371 | NSLog(message, uriValue); 372 | 373 | pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[[NSString alloc] initWithFormat:message, uriValue]]; 374 | } 375 | 376 | [self.commandDelegate sendPluginResult:pluginResult callbackId: command.callbackId]; 377 | }]; 378 | } else { // ios < 10 (Will be depreciated) 379 | [[UIApplication sharedApplication] openURL:[NSURL URLWithString:uriValue]]; 380 | } 381 | } 382 | 383 | @end 384 | -------------------------------------------------------------------------------- /scripts/after.prepare.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /** 4 | * The code below is copied from http://gist.github.com. All rights reserved 5 | * @see https://gist.github.com/marcocarnazzo/6f01a57d390e8fe3071f 6 | */ 7 | 8 | /** This hook updates platform configuration files based on preferences and config-file data defined in config.xml. 9 | Currently only the AndroidManifest.xml and IOS *-Info.plist file are supported. 10 | 11 | See http://stackoverflow.com/questions/28198983/ionic-cordova-add-intent-filter-using-config-xml 12 | 13 | Preferences: 14 | 1. Preferences defined outside of the platform element will apply to all platforms 15 | 2. Preferences defined inside a platform element will apply only to the specified platform 16 | 3. Platform preferences take precedence over common preferences 17 | 4. The preferenceMappingData object contains all of the possible custom preferences to date including the 18 | target file they belong to, parent element, and destination element or attribute 19 | 20 | Config Files 21 | 1. config-file elements MUST be defined inside a platform element, otherwise they will be ignored. 22 | 2. config-file target attributes specify the target file to update. (AndroidManifest.xml or *-Info.plist) 23 | 3. config-file parent attributes specify the parent element (AndroidManifest.xml) or parent key (*-Info.plist) 24 | that the child data will replace or be appended to. 25 | 4. config-file elements are uniquely indexed by target AND parent for each platform. 26 | 5. If there are multiple config-file's defined with the same target AND parent, the last config-file will be used 27 | 6. Elements defined WITHIN a config-file will replace or be appended to the same elements relative to the parent element 28 | 7. If a unique config-file contains multiples of the same elements (other than uses-permission elements which are 29 | selected by by the uses-permission name attribute), the last defined element will be retrieved. 30 | 31 | Examples: 32 | 33 | AndroidManifest.xml 34 | NOTE: For possible manifest values see http://developer.android.com/guide/topics/manifest/manifest-intro.html 35 | 36 | 37 | //These preferences are actually available in Cordova by default although not currently documented 38 | 39 | 40 | 41 | 42 | //custom preferences examples 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | *-Info.plist 63 | 64 | 65 | 66 | 67 | UIInterfaceOrientationLandscapeOmg 68 | 69 | 70 | 71 | 72 | someValue 73 | 74 | 75 | 76 | NOTE: Currently, items aren't removed from the platform config files if you remove them from config.xml. 77 | For example, if you add a custom permission, build the remove it, it will still be in the manifest. 78 | If you make a mistake, for example adding an element to the wrong parent, you may need to remove and add your platform, 79 | or revert to your previous manifest/plist file. 80 | 81 | TODO: We may need to capture all default manifest/plist elements/keys created by Cordova along with any plugin elements/keys to compare against custom elements to remove. 82 | 83 | == ABOUT THIS CODE == 84 | Original code was written by Devin Jett ( https://github.com/djett41 ) 85 | and then modified by Marco Carnazzo ( https://github.com/marcocarnazzo ). 86 | 87 | This hook is in public domain. 88 | */ 89 | 90 | // global vars 91 | var fs = require('fs'); 92 | var path = require('path'); 93 | var _ = require('lodash'); 94 | var et = require('elementtree'); 95 | var plist = require('plist'); 96 | 97 | var rootdir = path.resolve(__dirname, '../../'); 98 | 99 | var platformConfig = (function(){ 100 | /* Global object that defines the available custom preferences for each platform. 101 | Maps a config.xml preference to a specific target file, parent element, and destination attribute or element 102 | */ 103 | var preferenceMappingData = { 104 | 'android': { 105 | 'android-manifest-hardwareAccelerated': {target: 'AndroidManifest.xml', parent: './', destination: 'android:hardwareAccelerated'}, 106 | 'android-installLocation': {target: 'AndroidManifest.xml', parent: './', destination: 'android:installLocation'}, 107 | 'android-activity-hardwareAccelerated': {target: 'AndroidManifest.xml', parent: 'application', destination: 'android:hardwareAccelerated'}, 108 | 'android-configChanges': {target: 'AndroidManifest.xml', parent: 'application/activity[@android:name=\'CordovaApp\']', destination: 'android:configChanges'}, 109 | 'android-launchMode': {target: 'AndroidManifest.xml', parent: 'application/activity[@android:name=\'CordovaApp\']', destination: 'android:launchMode'}, 110 | 'android-theme': {target: 'AndroidManifest.xml', parent: 'application/activity[@android:name=\'CordovaApp\']', destination: 'android:theme'}, 111 | 'android-windowSoftInputMode': {target: 'AndroidManifest.xml', parent: 'application/activity[@android:name=\'CordovaApp\']', destination: 'android:windowSoftInputMode'} 112 | }, 113 | 'ios': {}, 114 | 'browser': {} 115 | }; 116 | 117 | /* Global object that defines tags that should be added and not replaced 118 | */ 119 | var multipleTags = { 120 | 'android': ['intent-filter'], 121 | 'ios': [] 122 | }; 123 | 124 | var configXmlData, preferencesData; 125 | 126 | return { 127 | rootDir: null, 128 | // Parses a given file into an elementtree object 129 | parseElementtreeSync: function (filename) { 130 | var contents = fs.readFileSync(filename, 'utf-8'); 131 | if(contents) { 132 | //Windows is the BOM. Skip the Byte Order Mark. 133 | contents = contents.substring(contents.indexOf('<')); 134 | } 135 | return new et.ElementTree(et.XML(contents)); 136 | }, 137 | 138 | // Converts an elementtree object to an xml string. Since this is used for plist values, we don't care about attributes 139 | eltreeToXmlString: function (data) { 140 | var tag = data.tag; 141 | var el = '<' + tag + '>'; 142 | 143 | if(data.text && data.text.trim()) { 144 | el += data.text.trim(); 145 | } else { 146 | _.each(data.getchildren(), function (child) { 147 | el += platformConfig.eltreeToXmlString(child); 148 | }); 149 | } 150 | 151 | el += '' + tag + '>'; 152 | return el; 153 | }, 154 | 155 | // Parses the config.xml into an elementtree object and stores in the config object 156 | getConfigXml: function () { 157 | if(!configXmlData) { 158 | configXmlData = this.parseElementtreeSync(path.join(this.rootDir || rootdir, 'config.xml')); 159 | } 160 | 161 | return configXmlData; 162 | }, 163 | 164 | /* Retrieves all from config.xml and returns a map of preferences with platform as the key. 165 | If a platform is supplied, common prefs + platform prefs will be returned, otherwise just common prefs are returned. 166 | */ 167 | getPreferences: function (platform) { 168 | var configXml = this.getConfigXml(); 169 | 170 | //init common config.xml prefs if we haven't already 171 | if(!preferencesData) { 172 | preferencesData = { 173 | common: configXml.findall('preference') 174 | }; 175 | } 176 | 177 | var prefs = preferencesData.common || []; 178 | if(platform) { 179 | if(!preferencesData[platform]) { 180 | preferencesData[platform] = configXml.findall('platform[@name=\'' + platform + '\']/preference'); 181 | } 182 | prefs = prefs.concat(preferencesData[platform]); 183 | } 184 | 185 | return prefs; 186 | }, 187 | 188 | /* Retrieves all configured xml for a specific platform/target/parent element nested inside a platforms config-file 189 | element within the config.xml. The config-file elements are then indexed by target|parent so if there are 190 | any config-file elements per platform that have the same target and parent, the last config-file element is used. 191 | */ 192 | getConfigFilesByTargetAndParent: function (platform) { 193 | var configFileData = this.getConfigXml().findall('platform[@name=\'' + platform + '\']/config-file'); 194 | 195 | return _.keyBy(configFileData, function(item) { 196 | var parent = item.attrib.parent; 197 | //if parent attribute is undefined /* or */, set parent to top level elementree selector 198 | if(!parent || parent === '/*' || parent === '*/') { 199 | parent = './'; 200 | } 201 | return item.attrib.target + '|' + parent; 202 | }); 203 | }, 204 | 205 | /** 206 | * Check if a tag can be used multiple times in config 207 | */ 208 | isMultipleTag: function(platform, tag) { 209 | var platformMultipleTags = multipleTags[platform]; 210 | if (platformMultipleTags) { 211 | var isInArray = (platformMultipleTags.indexOf(tag) >= 0); 212 | return isInArray; 213 | } else { 214 | return false; 215 | } 216 | }, 217 | 218 | // Parses the config.xml's preferences and config-file elements for a given platform 219 | parseConfigXml: function (platform) { 220 | var configData = {}; 221 | this.parsePreferences(configData, platform); 222 | this.parseConfigFiles(configData, platform); 223 | 224 | return configData; 225 | }, 226 | 227 | // Retrieves th e config.xml's pereferences for a given platform and parses them into JSON data 228 | parsePreferences: function (configData, platform) { 229 | var preferences = this.getPreferences(platform), 230 | type = 'preference'; 231 | 232 | _.each(preferences, function (preference) { 233 | var prefMappingData = preferenceMappingData[platform][preference.attrib.name], 234 | target, 235 | prefData; 236 | 237 | if (prefMappingData) { 238 | prefData = { 239 | parent: prefMappingData.parent, 240 | type: type, 241 | destination: prefMappingData.destination, 242 | data: preference 243 | }; 244 | 245 | target = prefMappingData.target; 246 | if(!configData[target]) { 247 | configData[target] = []; 248 | } 249 | configData[target].push(prefData); 250 | } 251 | }); 252 | }, 253 | 254 | // Retrieves the config.xml's config-file elements for a given platform and parses them into JSON data 255 | parseConfigFiles: function (configData, platform) { 256 | var configFiles = this.getConfigFilesByTargetAndParent(platform), 257 | type = 'configFile'; 258 | 259 | _.each(configFiles, function (configFile, key) { 260 | var keyParts = key.split('|'); 261 | var target = keyParts[0]; 262 | var parent = keyParts[1]; 263 | var items = configData[target] || []; 264 | 265 | _.each(configFile.getchildren(), function (element) { 266 | items.push({ 267 | parent: parent, 268 | type: type, 269 | destination: element.tag, 270 | data: element 271 | }); 272 | }); 273 | 274 | configData[target] = items; 275 | }); 276 | }, 277 | 278 | // Parses config.xml data, and update each target file for a specified platform 279 | updatePlatformConfig: function (platform) { 280 | var configData = this.parseConfigXml(platform), 281 | platformPath = path.join(this.rootDir || rootdir, 'platforms', platform); 282 | 283 | _.each(configData, function (configItems, targetFileName) { 284 | var projectName, targetFile; 285 | 286 | if (platform === 'ios' && targetFileName.indexOf("Info.plist") > -1) { 287 | projectName = platformConfig.getConfigXml().findtext('name'); 288 | targetFile = path.join(platformPath, projectName, projectName + '-Info.plist'); 289 | platformConfig.updateIosPlist(targetFile, configItems); 290 | } else if (platform === 'android' && targetFileName === 'AndroidManifest.xml') { 291 | targetFile = path.join(platformPath, targetFileName); 292 | platformConfig.updateAndroidManifest(targetFile, configItems); 293 | } 294 | }); 295 | }, 296 | 297 | // Updates the AndroidManifest.xml target file with data from config.xml 298 | updateAndroidManifest: function (targetFile, configItems) { 299 | var tempManifest = platformConfig.parseElementtreeSync(targetFile), 300 | root = tempManifest.getroot(); 301 | 302 | _.each(configItems, function (item) { 303 | // if parent is not found on the root, child/grandchild nodes are searched 304 | var parentEl = root.find(item.parent) || root.find('*/' + item.parent), 305 | data = item.data, 306 | childSelector = item.destination, 307 | childEl; 308 | 309 | if(!parentEl) { 310 | return; 311 | } 312 | 313 | if(item.type === 'preference') { 314 | parentEl.attrib[childSelector] = data.attrib['value']; 315 | } else { 316 | // since there can be multiple uses-permission elements, we need to select them by unique name 317 | if(childSelector === 'uses-permission') { 318 | childSelector += '[@android:name=\'' + data.attrib['android:name'] + '\']'; 319 | } 320 | 321 | childEl = parentEl.find(childSelector); 322 | 323 | // if child element doesnt exist, create new element 324 | 325 | var isMultipleTag = platformConfig.isMultipleTag('android', childSelector); 326 | if(!childEl || isMultipleTag) { 327 | childEl = new et.Element(item.destination); 328 | parentEl.append(childEl); 329 | } 330 | 331 | // copy all config.xml data except for the generated _id property 332 | _.each(data, function (prop, propName) { 333 | if(propName !== '_id') { 334 | childEl[propName] = prop; 335 | } 336 | }); 337 | } 338 | }); 339 | 340 | fs.writeFileSync(targetFile, tempManifest.write({indent: 4}), 'utf-8'); 341 | }, 342 | 343 | /* Updates the *-Info.plist file with data from config.xml by parsing to an xml string, then using the plist 344 | module to convert the data to a map. The config.xml data is then replaced or appended to the original plist file 345 | */ 346 | updateIosPlist: function (targetFile, configItems) { 347 | var infoPlist = plist.parse(fs.readFileSync(targetFile, 'utf-8')), 348 | tempInfoPlist; 349 | 350 | _.each(configItems, function (item) { 351 | var key = item.parent; 352 | var plistXml = '' + key + ''; 353 | plistXml += platformConfig.eltreeToXmlString(item.data) + ''; 354 | 355 | var configPlistObj = plist.parse(plistXml); 356 | infoPlist[key] = configPlistObj[key]; 357 | }); 358 | 359 | tempInfoPlist = plist.build(infoPlist); 360 | tempInfoPlist = tempInfoPlist.replace(/[\s\r\n]*<\/string>/g,''); 361 | fs.writeFileSync(targetFile, tempInfoPlist, 'utf-8'); 362 | } 363 | }; 364 | })(); 365 | 366 | // Main 367 | module.exports = function (ctx) { 368 | 369 | platformConfig.rootDir = ctx.opts.projectRoot; 370 | if (rootdir || platformConfig.rootDir) { 371 | // go through each of the platform directories that have been prepared 372 | var platforms = _.filter(fs.readdirSync('platforms'), function (file) { 373 | return fs.statSync(path.resolve('platforms', file)).isDirectory(); 374 | }); 375 | 376 | _.each(platforms, function (platform) { 377 | try { 378 | platform = platform.trim().toLowerCase(); 379 | platformConfig.updatePlatformConfig(platform); 380 | } catch (e) { 381 | process.stdout.write(e.toString() + "\n"); 382 | } 383 | }); 384 | } 385 | }; 386 | -------------------------------------------------------------------------------- /src/android/br/com/mfdeveloper/cordova/NativeView.java: -------------------------------------------------------------------------------- 1 | package br.com.mfdeveloper.cordova; 2 | 3 | import android.app.Activity; 4 | import android.content.ActivityNotFoundException; 5 | import android.content.ComponentName; 6 | import android.content.Intent; 7 | import android.content.pm.PackageInfo; 8 | import android.content.pm.PackageManager; 9 | import android.content.pm.ResolveInfo; 10 | import android.net.Uri; 11 | import android.os.Handler; 12 | import android.os.Message; 13 | import android.util.Log; 14 | 15 | import org.apache.cordova.BuildConfig; 16 | import org.apache.cordova.CallbackContext; 17 | import org.apache.cordova.CordovaInterface; 18 | import org.apache.cordova.CordovaPlugin; 19 | import org.apache.cordova.CordovaWebView; 20 | import org.apache.cordova.PluginResult; 21 | import org.json.JSONArray; 22 | import org.json.JSONException; 23 | import org.json.JSONObject; 24 | 25 | import java.lang.reflect.Field; 26 | import java.lang.reflect.InvocationTargetException; 27 | import java.lang.reflect.Method; 28 | import java.util.HashMap; 29 | import java.util.Iterator; 30 | import java.util.List; 31 | 32 | /** 33 | * Start a native Activity. This plugin 34 | * use Java Reflection to decide which method 35 | * execute 36 | * 37 | * Based and inspired by cordova plugin: com.lampa.startapp 38 | * 39 | * @author @mfdeveloper on 28/08/17 40 | * @see https://github.com/lampaa/com.lampa.startapp 41 | */ 42 | public class NativeView extends CordovaPlugin { 43 | 44 | private static final String TAG = "NativeViewPlugin"; 45 | protected HashMap marketUrls = new HashMap() {{ 46 | put("app", "market://details?id=%s"); 47 | put("web", "https://play.google.com/store/apps/details?id=%s"); 48 | }}; 49 | 50 | public void initialize(CordovaInterface cordova, CordovaWebView webView) { 51 | super.initialize(cordova, webView); 52 | 53 | Log.d(TAG, "Initializing " + TAG); 54 | } 55 | 56 | public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) { 57 | 58 | try { 59 | 60 | Method method = getClass().getMethod(action, JSONArray.class, CallbackContext.class); 61 | 62 | try { 63 | 64 | method.invoke(this, args, callbackContext); 65 | 66 | return true; 67 | 68 | } catch (IllegalAccessException e) { 69 | JSONObject error = errorResult(e); 70 | callbackContext.error(error); 71 | 72 | e.printStackTrace(); 73 | 74 | } catch (IllegalArgumentException e) { 75 | JSONObject error = errorResult(e); 76 | callbackContext.error(error); 77 | 78 | e.printStackTrace(); 79 | 80 | }catch (InvocationTargetException e) { 81 | JSONObject error = errorResult(e); 82 | callbackContext.error(error); 83 | 84 | e.printStackTrace(); 85 | } 86 | }catch (NoSuchMethodException e) { 87 | 88 | String message = String.format("Method with name: %s was not found on: %s\n Reason: %s", action, getClass().getName(), e.getMessage()); 89 | 90 | Log.d(TAG, message); 91 | 92 | HashMap data = new HashMap(); 93 | data.put("message", message); 94 | 95 | JSONObject error = errorResult(e, data); 96 | callbackContext.error(error); 97 | 98 | e.printStackTrace(); 99 | 100 | } 101 | 102 | return false; 103 | } 104 | 105 | public void show(JSONArray args, final CallbackContext callbackContext) throws JSONException { 106 | 107 | JSONObject activityParams = mountParams(args); 108 | 109 | 110 | final Intent intentToStart = configureIntent(args, activityParams, callbackContext); 111 | 112 | cordova.getThreadPool().execute(new Runnable() { 113 | @Override 114 | public void run() { 115 | 116 | try { 117 | /** 118 | * Reference: You can use "PendingIntent" to avoid open the Activity twice, 119 | * but the ActivityNotFound exception is never catch 120 | * 121 | * @see https://www.journaldev.com/10463/android-notification-pendingintent 122 | */ 123 | cordova.getActivity().startActivity(intentToStart); 124 | JSONObject success = new JSONObject(); 125 | success.put("success", true); 126 | success.put("message", "Native screen is started"); 127 | 128 | callbackContext.success(success); 129 | } catch (Exception e) { 130 | 131 | JSONObject error = errorResult(e); 132 | callbackContext.error(error); 133 | e.printStackTrace(); 134 | } 135 | 136 | } 137 | }); 138 | } 139 | 140 | public void showMarket(JSONArray args, final CallbackContext callbackContext) throws JSONException { 141 | 142 | JSONObject activityParams = mountParams(args); 143 | String targetPackage; 144 | 145 | if (activityParams.has("marketId")) { 146 | targetPackage = activityParams.getString("marketId"); 147 | }else{ 148 | 149 | targetPackage = activityParams.has("package") ? activityParams.optString("package") : activityParams.optString("packageApp"); 150 | } 151 | 152 | if (targetPackage == null || (targetPackage != null && targetPackage.length() == 0)) { 153 | JSONObject error = new JSONObject() {{ 154 | put("success", false); 155 | put("message", "The 'marketId' or 'package' is required"); 156 | }}; 157 | callbackContext.error(error); 158 | return; 159 | } 160 | 161 | final Intent intent = new Intent(Intent.ACTION_VIEW); 162 | final String packageName = targetPackage; 163 | 164 | cordova.getThreadPool().execute(new Runnable() { 165 | @Override 166 | public void run() { 167 | try { 168 | intent.setData(Uri.parse(String.format(marketUrls.get("app"), packageName))); 169 | cordova.getActivity().startActivity(intent); 170 | 171 | JSONObject result = new JSONObject() {{ 172 | put("success", true); 173 | put("uri", intent.getData().toString()); 174 | put("package", packageName); 175 | }}; 176 | 177 | callbackContext.success(result); 178 | 179 | } catch (ActivityNotFoundException activityErr) { 180 | 181 | try { 182 | intent.setData(Uri.parse(String.format(marketUrls.get("web"), packageName))); 183 | cordova.getActivity().startActivity(intent); 184 | 185 | JSONObject result = new JSONObject() {{ 186 | put("success", true); 187 | put("uri", intent.getData().toString()); 188 | put("package", packageName); 189 | }}; 190 | 191 | callbackContext.success(result); 192 | 193 | }catch (Exception err) { 194 | JSONObject error = errorResult(err); 195 | callbackContext.error(error); 196 | err.printStackTrace(); 197 | } 198 | }catch (Exception e) { 199 | 200 | JSONObject error = errorResult(e); 201 | callbackContext.error(error); 202 | e.printStackTrace(); 203 | } 204 | } 205 | }); 206 | } 207 | 208 | public void checkIfAppInstalled(JSONArray args, final CallbackContext callbackContext) throws JSONException { 209 | 210 | final JSONObject activityParams = mountParams(args); 211 | final Intent intent = configureIntent(args, activityParams, callbackContext); 212 | 213 | PackageManager packManager = this.cordova.getActivity().getApplicationContext().getPackageManager(); 214 | 215 | // Get all activities that respond to the configured Intent (by uri, package etc..) 216 | final List listInfo = packManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); 217 | 218 | if (listInfo.size() > 0) { 219 | 220 | JSONObject result = new JSONObject() {{ 221 | put("success", true); 222 | put("packageName", listInfo.get(0).activityInfo.packageName); 223 | put("applicationInfo", listInfo.get(0).activityInfo.toString()); 224 | put("activityName", listInfo.get(0).activityInfo.name); 225 | }}; 226 | 227 | callbackContext.success(result); 228 | 229 | } else { 230 | JSONObject error = new JSONObject() {{ 231 | put("success", false); 232 | put("message", "App not found"); 233 | put("intent", intent.toString()); 234 | put("action", intent.getAction()); 235 | put("params", activityParams); 236 | }}; 237 | callbackContext.error(error); 238 | } 239 | } 240 | 241 | public void getBuildVariant(JSONArray args, final CallbackContext callbackContext) { 242 | 243 | if (args.length() > 0) { 244 | 245 | try{ 246 | 247 | JSONObject params = args.getJSONObject(0); 248 | 249 | if (params.has("catchError") && params.optBoolean("catchError", true)) { 250 | 251 | if (BuildConfig.FLAVOR == null || BuildConfig.FLAVOR.length() == 0) { 252 | 253 | JSONObject error = new JSONObject(); 254 | error.put("success", false); 255 | error.put("message", "The FLAVOR is not defined. Verify your build.gradle 'productFlavors' config"); 256 | 257 | callbackContext.error(error); 258 | return; 259 | } 260 | } 261 | 262 | }catch (JSONException e) { 263 | JSONObject error = errorResult(e); 264 | 265 | callbackContext.error(error); 266 | } 267 | } 268 | 269 | 270 | callbackContext.success(BuildConfig.FLAVOR); 271 | } 272 | 273 | protected JSONObject mountParams(JSONArray args) throws JSONException { 274 | 275 | JSONObject activityParams; 276 | 277 | if (args.opt(0) instanceof JSONObject) { 278 | activityParams = new JSONObject(args.getJSONObject(0).toString()); 279 | }else { 280 | activityParams = new JSONObject(); 281 | activityParams.put("packageName", args.optString(0)); 282 | activityParams.put("className", args.optString(1)); 283 | } 284 | 285 | return activityParams; 286 | } 287 | 288 | protected Intent configureIntent(JSONArray args, JSONObject activityParams, CallbackContext callbackContext) throws JSONException { 289 | Intent intent = new Intent(); 290 | intent = intentFromUri(intent, activityParams, callbackContext); 291 | 292 | if (!(intent.getData() instanceof Uri)) { 293 | 294 | String targetPackage = activityParams.has("package") ? activityParams.optString("package") : activityParams.optString("packageApp"); 295 | 296 | if (targetPackage != null && targetPackage.length() > 0) { 297 | 298 | intent.setPackage(targetPackage); 299 | } 300 | 301 | intent = intentFromClass(intent, activityParams, callbackContext); 302 | 303 | intent = intentFromComponent(intent, activityParams, callbackContext); 304 | } 305 | 306 | addFlags(intent, activityParams, callbackContext); 307 | 308 | addExtraParams(args, activityParams, intent); 309 | return intent; 310 | } 311 | 312 | protected Intent intentFromComponent(Intent intent, JSONObject activityParams, CallbackContext callbackContext) throws JSONException { 313 | 314 | if(activityParams.has("component")) { 315 | JSONObject component = activityParams.getJSONObject("component"); 316 | 317 | if(component.has("packageApp") && component.has("className")) { 318 | if (!component.getString("className").startsWith(".")) { 319 | component.put("className", component.getString("packageApp") + "." + component.getString("className")); 320 | } 321 | intent.setComponent(new ComponentName(component.getString("packageApp"), component.getString("className"))); 322 | } else { 323 | 324 | JSONObject error = new JSONObject(); 325 | error.put("success", false); 326 | error.put("message", "The 'component' key needs contains 'packageApp' and 'className' args"); 327 | 328 | callbackContext.error(error); 329 | throw new RuntimeException(error.getString("message")); 330 | } 331 | } 332 | return intent; 333 | } 334 | 335 | protected Intent intentFromUri(Intent intent, JSONObject activityParams, CallbackContext callbackContext) throws JSONException { 336 | 337 | if(activityParams.has("uri")) { 338 | 339 | String action = Intent.ACTION_VIEW; 340 | 341 | if (activityParams.has("action")) { 342 | try{ 343 | action = (String) getIntentValue(activityParams.optString("action")); 344 | }catch (Exception intentErr) { 345 | JSONObject error = errorResult(intentErr); 346 | callbackContext.error(error); 347 | 348 | intentErr.printStackTrace(); 349 | } 350 | } 351 | 352 | intent.setAction(action); 353 | intent.addCategory(Intent.CATEGORY_DEFAULT); 354 | intent.addCategory(Intent.CATEGORY_BROWSABLE); 355 | intent.setData(Uri.parse(activityParams.getString("uri"))); 356 | } 357 | 358 | return intent; 359 | } 360 | 361 | protected Intent intentFromClass(Intent intent, JSONObject activityParams, CallbackContext callbackContext) throws JSONException { 362 | 363 | if (activityParams.has("className") && activityParams.has("packageName")) { 364 | 365 | try { 366 | 367 | intent = new Intent(activityParams.optString("packageName") + "." + activityParams.getString("className")); 368 | intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 369 | 370 | }catch (Exception clsErr) { 371 | JSONObject error = errorResult(clsErr); 372 | 373 | callbackContext.error(error); 374 | clsErr.printStackTrace(); 375 | } 376 | }else{ 377 | JSONObject error = new JSONObject(); 378 | error.put("message", "The params 'packageName' and 'className' is required"); 379 | error.put("sucess", false); 380 | 381 | callbackContext.error(error); 382 | } 383 | 384 | return intent; 385 | } 386 | 387 | protected void addFlags(Intent intent, JSONObject activityParams, final CallbackContext callbackContext) { 388 | 389 | 390 | JSONArray flags = activityParams.optJSONArray("flags"); 391 | 392 | if (flags == null) { 393 | flags = new JSONArray(); 394 | } 395 | 396 | // Add default flags 397 | flags.put(Intent.FLAG_ACTIVITY_CLEAR_TOP); 398 | 399 | for(int i=0; i < flags.length(); i++) { 400 | Integer flagValue; 401 | try{ 402 | 403 | if (flags.get(i) instanceof String) { 404 | flagValue = (Integer) getIntentValue(flags.getString(i)); 405 | }else{ 406 | flagValue = flags.getInt(i); 407 | } 408 | 409 | intent.addFlags(flagValue.intValue()); 410 | }catch (Exception intentErr) { 411 | JSONObject error = errorResult(intentErr); 412 | callbackContext.error(error); 413 | } 414 | } 415 | 416 | } 417 | 418 | protected void addExtraParams(JSONArray args, JSONObject activityParams, Intent intent) throws JSONException { 419 | JSONObject jsonExtra; 420 | if (activityParams.opt("className") instanceof JSONObject) { 421 | jsonExtra = activityParams.getJSONObject("className"); 422 | } else { 423 | 424 | if (args.length() == 2 && args.opt(0) instanceof JSONObject) { 425 | jsonExtra = args.optJSONObject(1); 426 | }else{ 427 | 428 | jsonExtra = args.length() >= 3 ? args.getJSONObject(2) : activityParams.optJSONObject("params"); 429 | } 430 | 431 | } 432 | 433 | if (jsonExtra != null) { 434 | 435 | Iterator> keys = jsonExtra.keys(); 436 | 437 | while (keys.hasNext()) { 438 | String key = (String) keys.next(); 439 | Object value = jsonExtra.get(key); 440 | 441 | if(value instanceof Integer) { 442 | intent.putExtra(key, jsonExtra.getInt(key)); 443 | } 444 | 445 | if(value instanceof String) { 446 | intent.putExtra(key, jsonExtra.getString(key)); 447 | } 448 | 449 | if(value instanceof Boolean) { 450 | intent.putExtra(key, jsonExtra.getBoolean(key)); 451 | } 452 | } 453 | } 454 | } 455 | 456 | protected JSONObject errorResult(Exception e) { 457 | HashMap data = new HashMap(); 458 | data.put("success", false); 459 | data.put("name", e.getClass().getName()); 460 | data.put("message", e.getMessage() != null ? e.getMessage() : e.getCause().getMessage()); 461 | 462 | JSONObject error = new JSONObject(data); 463 | return error; 464 | } 465 | 466 | protected JSONObject errorResult(Exception e, HashMap extraData) { 467 | HashMap data = new HashMap(); 468 | data.put("success", false); 469 | data.put("name", e.getClass().getName()); 470 | data.put("message", e.getMessage() != null ? e.getMessage() : e.getCause().getMessage()); 471 | 472 | data.putAll(extraData); 473 | 474 | JSONObject error = new JSONObject(data); 475 | return error; 476 | } 477 | 478 | protected Object getIntentValue(String flag) throws NoSuchFieldException, IllegalAccessException { 479 | Field field = Intent.class.getDeclaredField(flag); 480 | field.setAccessible(true); 481 | 482 | return field.get(null); 483 | } 484 | } 485 | --------------------------------------------------------------------------------
If you get lost, the docs will be your guide.