Search This Blog

Tuesday 29 December 2015

iphone distribution has not been trusted on this iphone (or) iOS 9: How to trust enterprise developer profiles

In ios9, you may receive a message when trying to open an app from enterprise stores of some companies. In that case you need to trust that enterprise from settings,

Settings->General->Profiles
select the enterprise profile and tap on trust.

Reference:
https://support.apple.com/en-us/HT204460
http://blog.aceontech.com/post/123970856398/ios-9-how-to-trust-enterprise-developer-profiles

Thursday 10 December 2015

Enabling click to call and mail in android using ionic/cordova

by default in android tel and mailto are blocked in cordova/ionic.

to enable click to call/mail feature you can use one of below ways:

Option 1:

a. Install whitelist cordova plugin
       ionic plugin install cordova-plugin-whitelist
b.add the below lines to config.xml of your project
   <access origin="tel:*" launch-external="yes" />
   <access origin="mailto:*" launch-external="yes" />
now when you give your phone the below way, it will copy the number to dailing pad.
      <a href="tel:{{Contact.phone}}" style="margin-top: 10px;" class="button icon-left ion-ios-        telephone">{{Contact.phone}}</a>

Option 2:


$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|sip|chrome-extension):/);

add it in the app.js, dont forget to add $compileProvide dependency.

Monday 23 November 2015

Mac shortcuts

create a new folder - Command + Shift + N
connect to server - Command + K - to open any shared folder
Spotlight Search - Command + Spacebar
Open a file - Command + O
open task manager to kill - Command+Option+Esc

Friday 20 November 2015

Billing software for small retail stores

Here i am sharing the source code of a billing software i recently did. Its web technologies based with features like, billing, printing and admin page.


Here are the technologies used:

  • HTML
  • CSS
  • Bootstrap 3
  • PHP
  • MySql
  • jquery-ui
using XAMPP server

plugins used:


Development Brief:
  • Started with appendgrid to add items to bill list. its cool and easy to use jquery plugin for creating dynamic tables. Good user guide is provided with it and firm support from the developer alert
  • crypto-js i found easy. used md5 hashing to encrypt and store passwords in mysql db. (genuinely i dont know that we cant password from hash, later i came to know. you are free to use what ever u like by doing the changes in necessary places)
  • for showing items in left panel used jplist for DOM item filtering and pagination purposes. its cool easy to use plugin 
  • Admin tab will be available under options for admin users. through which they can add/change items, users, get stores reports and can see bill reports daily, weekly, monthly and custom dates.
  • admin can export reports to excel. phpexcel is used for writing data to excel from php which is retrieved from mysql
  • Jquery-ui is used for most of the ui parts along with bootstrap. some flaws are there in responsiveness :P ;). works well in all normal sized screens.

Thursday 19 November 2015

View/show/open documents in ionic

To see documents using cordova a plugin is available called DocumentHandler
using this you can directly open a remote files of type pdf,docx,xlsx,ppt,txt

to install the plugin:
ionic plugin add https://github.com/ti8mag/DocumentHandler.git

after installing to view a document use the following snippet:

window.handleDocumentWithURL(function() { console.log('success'); },
                             function(error) { console.log('failure'); if (error == 53) { console.log('No app that handles this file type.'); } },
                             "path-to-file");

path can be a local path or a remote path

if you want to download and then show you need to use FileTransfer and File cordova API's first to get the file and then you can use DocumentHandler plug-in to show a file

ionic plugin add cordova-plugin-file  // file is to choose local storage location
ionic plugin add cordova-plugin-file-transfer // file-transfer to download a file

use the below code to download and show

var fileTransfer = new FileTransfer();
    var uri = encodeURI("http://media.metro.net/riding_metro/bus_overview/images/230.pdf");
    $window.alert("uri:"+uri);
    console.log("uri:"+uri);
    var store = cordova.file.dataDirectory;
    var fileName = "365.pdf";
            fileTransfer.download(
                                  uri,
                                  store+fileName,
                                  function(entry) {
                                  $window.alert("download complete: " + entry.toURL());
                                  console.log("download complete: " + entry.toURL());
                                  window.handleDocumentWithURL(function() { console.log('success'); },
                                  function(error) { console.log('failure'); if (error == 53) { console.log('No app that handles this file type.'); } },
                                  entry.toURL());
                                  },
                                  function(error) {
                                  $window.alert("download error source " + error.source+"download error source " + error.source);
                                  console.log("download error source " + error.source);
                                  console.log("download error target " + error.target);
                                  console.log("upload error code" + error.code);
                                  },
                                  false,
                                  {
                                  headers: {
                                  "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
                                  }
                                  }
                                  );

DocumentHandler gives additional options to share the files. good & easy to use plugin

Note: it uses quicklook framework in ios, and in android it give a list of open with options to open the doc

Wednesday 11 November 2015

Ionic 2 with Angular 2

                Ionic 2 Alpha has been released: http://blog.ionic.io/announcing-ionic-2-0-alpha/ .
As the hardware capabilities are increasing and new technologies have emerged (Specially Angular 2 which is to support new ES6 standard) ionic is working on releasing ionic 2.

Like in Angular 1 is base in ionic 1, Angular 2 in ionic 2. Angular 2 can be scripted in either ES6 or in TypeScript, which is a Microsoft supported language for java script.
As of now no good tutorials are available for angular 2, ionic has done a decent work: http://ionicframework.com/docs/v2/getting-started/installation/
More about angular 2 @ http://ng-learn.org/2014/03/AngularJS-2-Status-Preview/ (I didn’t completely read this, felt little better compared to other posts in net).

My first impressions on ionic/angular 2:
  •       No ng-app, No ng-controller
  •       No two way data binding (big change up to me)
  •       Introduced Components
  •       Services/Providers, Directives will act the same way
  •       Classes, imports, this operator have been introduced
  •       All are custom tags. Dependent completely on directives


Yet to explore….


Thursday 24 September 2015

create ionic app with appname and id

we create ionic app just by saying:
ionic start YourAppName blank

if you create app this way, problem will come after building ios/android app.
you need to edit config.xml . if you want to give app name and bundle id while creating project itself use the below command.

ionic start YourAppName blank --appname YourApp --id com.yourcomapny.yourapp

Wednesday 23 September 2015

Signing and Generating .apk for Ionic apps

ionic build android will give you an unsigned apk file. unsigned apk is not accepted in play store. so you need to sign and make .apk to release to play store.

Building Ionic Android app:
ionic build --release android
This will generate a release build based on the settings in your config.xml. Your Ionic app will have preset default values in this file, but if you need to customize how your app is built, you can edit this file to fit your preferences. Check out the config.xml file documentation for more information.
Now, we can find out unsigned apk in \platforms\android\ant-build\MainActivity-release-unsigned.apk
app name "MainActivity" looks ugly. to change the app name follow the steps below:
You will need to update the following files:
  1. YourProjectName/platforms/android/AndroidManifest.xml
  2. YourProjectName/platforms/android/build.xml
  3. YourProjectName/platforms/android/src/com/yourpackagename/appfolder/MainActivity.java
STEP 1
Got to the AndroidManifest.xml file and look for:
<activity android:configchanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchmode="singleTop" android:name="MainActivity" android:screenorientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowsoftinputmode="adjustResize">
change MainActivity to whatever name you want. ex:ItsMyCodeShare
STEP 2: In the build.xml file locate the following line:
<project name="MainActivity" default="help">
Change MainActivity to the name of your project and should match the one in put in step 1 (i.e  name="ItsMyCodeShare").
STEP 3 This stage is abit more tricky and extra caution should be taken when doing this, or else you  might mess things up big time...and that is not Awesome!!
  • Locate the file MainActivity.java and rename it to project name (Same as step 1 and 2...i.e ItsMyCodeShare.java).
  • Open the renamed file and locate the line : public class MainActivity extends CordovaActivity change it to the project name like: public class ItsMyCodeShare extends CordovaActivity
Sorry to disappoint you but.....That's it!!!
Run the command : ionic build android --release
more so, we are ready with our desired name.apk file.
Lets start signing it now.
1) Generate Private key
2) Sign the apk
3) zip the apk
For the above steps you will be using keytool, jarsigner and zipalign tools respectively.
1)keytool will be available in "C:\Program Files\Java\jre7\bin"
2)jarsigner will be available in "C:\Program Files\Java\jdk1.7.0_79\bin"
3)zipalign will be available in "C:\Users\e571224\AppData\Local\Android\sdk\build-tools\22.0.1"
Note:build-tools version(22.0.1) might vary depending on your installed version.
Step 1:
 we need to generate a private key using keytool of JDK.
open your command prompt and enter keytool. if it is not recognized add your jre/bin to Path environment variable.
Then, use the following command to generate the private key
keytool -genkey -v -keystore yourapp-release-key.keystore -alias app_alias_name -keyalg RSA -keysize 2048 -validity 10000
yourapp-release-key.keystore is now generated in that folder. copy and keep it safe.
It will ask for a password, followed by some security questions. remember the password.(take a screenshot to be on safer side)
Step 2:
we need to sign our unsigned apk with the above private key.
copy the private key (yourapp-release-key.keystore, generated in above step) into the folder in which your apk is present. Also, make sure to add the jdk/bin to Path environment variable.
now, run the below command to sign it.
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore yourapp-release-key.keystore yourapp-release-unsigned.apk app_alias_name
enter the password and your apk is signed now. 
Step 3:
we use the zipalign tool to generate the apk. zipalign is available in build-tools/yourversion. add that path to your environment variables.
Now, run the below command to generate the apk:
zipalign -v 4 yourapp-release-unsigned.apk ItsMyCodeShare.apk
this will generate the apk file which you can ship to play store.
References:
http://ionicframework.com/docs/guide/publishing.html
http://forum.ionicframework.com/t/renaming-android-build-apk-from-cordovaapp-to-your-app-name/15416

Friday 28 August 2015

Ionic View - explained

Ionic came up with a good idea for releasing the apps for QA/UAT and also kind of sharing.
i will just explain the steps to use this feature.

Pre-requisite:
you and the recipient to whom you want to send should have Ionic accounts. go to this link and sign up to get an account https://apps.ionic.io/


Step 1:
create the project in ionic (as you do normally)
ionic start testapp blank

you can add platforms, push notifications and do the development as you want.
Step 2:
Now you need to upload this app.
go to the app directory (cd appname).
then use this command to upload : ionic upload

Step 3:
you can share the app with the person by using the below command.
ionic share test1234@test.com

Step 4:
The sharing is through the account associated with that email and ionic view mobile app.
you can download the ionic view mobile app from Play store and App Store.

Step 5:
Sign into the app with the registered mail id. here it is test1234@test.com. then you can find the app there.
Step 6:
If you click on an app it will show you a menu as below:
 Step 7:
If you select View App, it will get downloaded and it will show as like an installed App. sample screenshot for reference.
Easy way to share app....!!! 


Thank the Ionic team for their work to bring new features to simplify developers job.

Ionic Framework Installation

Installing Ionic framework is pretty simple and straight forward.
Follow the below steps to complete it.

1. All Ionic installations are based on node.js. So, first install nodejs.
you can get the latest version of nodejs here: https://nodejs.org/download/

2. After installing nodejs, first you need to have Cordova. run the below command in command prompt: npm install -g cordova

Now you have installed, nodejs and Cordova. All ionic project templates are stored in Git. So you need Git to start any project in Ionic,

3. Install latest version of Git from : http://git-scm.com/

4. Install ionic framework. run the below command
npm install -g ionic

That's it. your Ionic is ready to start. to test give the following command in cmd prompt: ionic start testapp blank


Sunday 16 August 2015

Print Stylesheet Emulation/Debugging in Chrome


CSS for printing a div:

html body *{
display:none;
}
#printBillDIv , #printBillDIv  *
{
display:block !important;
}

Emulation /Debugging


  • Under Emulation > Media check CSS media and select print (3).Emulate print media query on Chrome v43

    • Open the Developer tools (CTRL+SHIFT+I or F12)
    • Click the Toggle device mode button in the left top corner (1).
    • Make sure the drawer is shown by clicking the Show drawer button (2) or pressing the ESC key to toggle the drawer.
    • Source: http://stackoverflow.com/questions/9540990/using-chromes-element-inspector-in-print-preview-mode 

    Tuesday 19 May 2015

    Service vs provider vs factory vs Value vs Constant in angularjs

    All Services are singletons; they get instantiated once per app. They can be of any type, whether it be a primitive, object literal, function, or even an instance of a custom type.
    The valuefactoryserviceconstant, and provider methods are all providers. They teach the Injector how to instantiate the Services.
    The most verbose, but also the most comprehensive one is a Provider recipe. The remaining four recipe types — Value, Factory, Service and Constant — are just syntactic sugar on top of a provider recipe.
    • The Value Recipe is the simplest case, where you instantiate the Service yourself and provide the instantiated value to the injector.
    • The Factory recipe gives the Injector a factory function that it calls when it needs to instantiate the service. When called, the factory function creates and returns the service instance. The dependencies of the Service are injected as the functions' arguments. So using this recipe adds the following abilities:
      • Ability to use other services (have dependencies)
      • Service initialization
      • Delayed/lazy initialization
    • The Service recipe is almost the same as the Factory recipe, but here the Injector invokes aconstructor with the new operator instead of a factory function.
    • The Provider recipe is usually overkill. It adds one more layer of indirection by allowing you to configure the creation of the factory.
      You should use the Provider recipe only when you want to expose an API for application-wide configuration that must be made before the application starts. This is usually interesting only for reusable services whose behavior might need to vary slightly between applications.
    • The Constant recipe is just like the Value recipe except it allows you to define services that are available in the config phase. Sooner than services created using the Value recipe. Unlike Values, they cannot be decorated using decorator.

    Tuesday 17 February 2015

    Match a string against a List of Regex Patterns in C# - Better way

    when you have list of Regex Patterns and you want to check whether your string matches any one of the patterns, then doing it using Lamda Expressions is an efficient way.

    Code:
    using System;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;

    public class Program
    {
    public static void Main()
    {

    List<Regex> lstpat= new List<Regex>();
    lstpat.Add(new Regex(@"\d{2}"));
    lstpat.Add(new Regex(@"\d{4}"));
    string str = "qqw1q1q2q1q2q2q3qqwqw";

    if(lstpat.Exists(x=>x.Match(str).Success == true))
    System.Console.Write("exists");
    else
    System.Console.Write("no");
    }

    }

    Output
    no

    if i give str = "qq11";

    output will be exists.

    if you are not doing it using Lamda Expressions you may need to write one loop for finding Matches.
                        foreach (Regex pattern in lstSmartTagPatterns)
                        {
                            lstMatches.Add(pattern.Match(str));
                        }
    then i need find a Match found or not in another loop.
                        foreach (Match result in lstMatches)
                        {
                            if(result.Success)
                                       System.Console.Write("exists");
                             else
                                       System.Console.Write("Doesnt exist");
                        }

    found doing first way is better. open for improvements.. share urs...