How to deploy a different version of index.html for PWA and native Apps with Ionic 2 - ionic2

our PWA lives here: https://m.quemesa.com and we also have native apps with the same codebase.
However, we are not targeting the Cordova Browser platform (because it does not seem to be officially supported and I can’t see what benefit it adds) so we have to add slightly different code for our PWA compared to our native app builds. For example, In the PWA, we use the pure Google Analytics solution which requires 2 lines of javascript in the index.html.
For our native builds, we use the Cordova GA plugin, so this is not required. In the PWA we don’t need to link to Cordova.js and Vendor.js for exmaple (they get a 404 error). In the native apps we do.
Currently I am manually editing (yuck) the output folder before uploading to Azure for the PWA.
Is there some way to edit the Ionic Build Process so that I can either have 2 versions of the Index and it grabs the one it wants for the output folder depending on the build type OR it can modify the html file at build time?

The current ionic build tool alone doesn't support this.
You could just have 2 versions of index.html and a small script to swap between them and build both versions.
It's also something you could do with a "full" CI build tool. Since you mentioned Azure you could make use of Visual Studio Team Services. There are existing tasks available for npm (to install ionic, run a PWA build) and running command/PowerShell scripts. It may be easier to start off by setting up an "agent" VM with everything it needs to build your app (node, ionic, Android studio, etc) then build your build process up from there.

I use gulp-preprocessto update index.html on build depending on platform targeted. The idea of the preprocess is to generate a target index.html before the ionic serve/build with the exact declarations required for the mode selected, pwa or native. More details on this post "Using Ionic/Cordova app sources as PWA"

Related

How to Debug Ionic WebApp?

I want to debug my ionic application in WebStorm.
I am able to run the app in browser. But how can I debug?
I tried: ionic serve --debug which doesn't seem to trigger any debugging?
How can I debug the app when it runs in browser?
With Chrome you can type chrome://inspect into your address bar
As soon as you are running your Android app, you can inspect the app when you are running it with the "ionic run android" or "ionic emulate android" command
The version of Android, however, must be higher than 4.3 I think...
According to the documentation there's a few different way's to do this. Also could you try one of these listed below since you have tried ionic serve already?
ionic run
ionic emulate
The run or emulate command will deploy the app to the specified platform devices/emulators. You can also run live reload on the specified platform device by adding the --livereload option. The live reload functionality is similar to ionic serve, but instead of developing and debugging an app using a standard browser, the compiled hybrid app itself is watching for any changes to its files and reloading the app when needed. This reduces the requirement to constantly rebuild the app for small changes.
Hope this get's you going! Let me know how it work's out for you.
I found this tool very useful, you can attach your device and get a real time inspector on your Cordova app(for iOS and Android platforms).
The browser is where I do most of my debugging for ionic. What browser are you using to do the debugging? I use Chrome and turn on DevTools. There is a source tab where you can browse your app code to find spots for breakpoints. For example, you can set a breakpoint in the code for a controller on a click event and step through the code. Then, you can use the console to execute commands to test values and inspect objects, etc. Are you unable to make this work? Or, unfamiliar w/ the DevTools? If unfamiliar, there is a resource available here. If not working, are the breakpoints not being hit?
There are a few ways to debug your ionic app.
In the browser you can catch the errors in the console.
If you are emulating your app on a simulator or a mobile device you can install the cardova plugin that displays js errors in the xcode console. So you can emulate your device and catch errors on xcode.
Here is how you add the plugin:
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
An alternative is using ionicLab. It worked for me doing the steps: Install the program and prepare all the project dependencies prior to testing. Then, click on Serve option from Testing which is under Platform menu. When the project has been executed, click on the arrow icon of the Preview bar.
As a result, Ionic will throw a Chrome window with the loaded project, so, you can use Developer Tools as it's used commonly. You ought to watch the javascript files, which you use in your project, so that you can debug them.
Simply run: ionic serve -l and inspect from browser developer options.

Security with Appcelator Titanium

I want to use Appcelator Titanium for Mobile App Development,But I am really concerned about the security of my code.
I studied some of the Android apps developed in Appcelator Titanium but from .apk file ,I am easily able to extract the logic part i.e. .jsfiles,.mp3 files etc, Which means my whole code is not secured.
Can anyone Please tell me how can I protect my code developed in Appcelator Titanium..?
Are you sure you are looking at an APK built for distribution in the app store i.e. build with
ti build -p android -T dist-playstore
Development version are not packed etc. Also generally what ever you use to build your app the resources are fairly easy to extract

Two RCP Applications in one installation

I recenty developed an Eclipse RCP application based on an existing RCP application. It´s basically used as a url protocol handler which reuses authentication and some services. I´m trying to avoid a second installation and look for a way to integrate the new RCP application into the installation of the existing RCP - is there a way to achieve this?
I´m (still) using Eclipse 3.8 and build with tycho.
Assuming that you have multiple applications within your product, you can launch the desired one using the
-application id
runtime argument.
In our application, which integrates multiple Eclipse RCP applications, we have a custom target platform, which bundles all other application plugins, so everything is shipped together. Also, all artifacts, provided by other applications can be retrieved from the maven repository, so that necessary services may be added as a dependencies to, for instance, server side projects. Hope that helps.

Deploying a Firebreath plugin on a webpage without manual installation

Recently I have been experimenting with Firebreath and developed a plugin in order to showcase my c++ projects on my portfolio website. I would like to make it easy for users to look at the projects without downloading files if they are new on my website.
The only issue I have at this point is that when users visit my page, they will receive a message indicating the plugin is missing. I would like to have an option for the users to automatically install my plugin without having to manually download and run it.
The plugin is mainly targetted at Windows users, since the applications are as well. I intend to support Google Chrome, Firefox, Internet Explorer. Currently I am using a MSI installer to install the plugin.
I have found a question similar to this, but I still needed to save the MSI installer and run it.
My question is: What would be the best way to implement this?
There isn't any way to "automatically" do what you want to do. The closest that I have heard of would be to use a java applet that would download and install the plugin for them. This can be pretty reliable on Mac but far less reliable on windows (for a number of reasons, among which the fact that many windows users don't have java installed and that Chrome blocks java applets by default without intervention by the user).
Other options include:
Creating a CAB file installer (only works on IE)
Creating a XPI firefox extension that packages the plugin (requires restarting the browser, only works on firefox)
Creating a CRX chrome extension that packages the plugin (only works on Chrome)
Microsoft ClickOnce used to work pretty well for one click installs of MSI files from a web page, but recently I think it doesn't work on many (if any) browsers; haven't seen it used in awhile, anyway.
There is no "automatic" way to install plugins; that would be considered a severe security issue. This is probably the #1 reason that plugins are as uncommon as they are.
do what adobe does,
create a tiny activeX application downloader, sign the activeX from with cheap SSL
when a user, enters your site, he will automatically be downloading this tiny ActiveX, after installation complete, inside the tiny ActiveX, have some type of batch script to download the EXE from remote server and silently install it.
adobe does this, on every reboot in boot.ini or startups
very easy

Silverlight 5 breaking Silverlight 4 application

I recently installed silverlight 5 and started working on new project based on SL5 version but after installing SL5 all my previous applications built on SL4 are not working and when i run these applications, XAP is getting downloaded and I am getting complete white screen as soon as it completed downloading XAP file and getting "AG_E_UNKNOWN_ERROR".
FYI: Everything works fine when i browse these SL4 based applications (hosted on my system) from a different system having only SL4 plugin.
Is there any known compatibility issue exists with SL4 & SL5 plugins running parallel? Kindly let me know any workarounds for this issue?
Thanks.
If you use Binding to Resource Files
You should update the constructor back to the public.
Also it might be possible that you web services references were broken