четверг, 16 октября 2014 г.

PhoneGap Build

PhoneGap Build

enter image description here

With phone gap build you can magically build source for many platforms at once.

Quirks here

  • Verify usage of latest phonegap version
  • Verify all depended plugins and plugins have the same version
  • DisableBouncyScrolling attribute for winphone work on local build but doesn’t work for phonegap build.

Written with StackEdit.

Organized chaos

Ionic / Cordova - Organized Chaos

enter image description here

Problems with weinre

  • It refuses to work with windows phone (it freezes application on the start, when weinre script included)
  • Run, not just wenire, but --boundHost 127.0.0.15 --httpPort 9090 and script in index.html should be http://127.0.0.15:9090/target/target-script-min.js#anonymous‘, where 127.0.0.15 is your local ip, (windows command : ipconfig - see vp4)

Icons / Splashes

Too many different resolutions to support.
Use imagemagic to convert different icons and screens from single source.
These scripts generate and copy resources to the appropriate device project folders (hooks/after_prepare).

Lock screen rotation

  • For android and ios (config.xml)
<preference name="orientation" value="portrait" />
  • For wp8 (MainPage.xaml)
SupportedOrientations="Portrait" Orientation="Portrait"

Deploy to Android

If can’t deploy to some android device, use this

Written with StackEdit.

Auth in cordova

Authorization in Cordova

enter image description here

The standard authentication model via session, doesn’t work in cordova application since requests doesn’t support cookies in requests (you could workaround it but you shouldn’t), it is usually recommended use token based authorization.

Considering social app authorization there 3 options

  • Write all yourself (possible only if you suppose utilize couple providers, still burden)
  • auth0 too expensive
  • outhio viable

The con of oauthio, it is support only session based authorization, hence you needed transform the recommended server side example to token based auth.

  • Authorize as in example via session, trick here in sigin you should manually set session.crf_tokens from body parameter, since session cookies not available in cordova apps. Happily crf_tokens is just array of tokens provisioned by getToken() method and since your client get this token on first auth step, just pass it to the second step.
  • After signin method invoke immediately me() method, grab user store him into db, if necessary, and create jwt token, every since after you could utilize only jwt token to validate you user.

Written with StackEdit.

понедельник, 22 сентября 2014 г.

Ionic and WP8



Still, there is no official support for windows phone apps in ionic framework, fortunately guys working on it. Still you can try it right now, each new version of framework make it smoother build ionic wp8 app.

There is some links and troubleshoots learned while building surf-better application.

1. This thread summarize basic wp8 problems
2. This is current version of MainPage.xaml corrected accordingly.
3. Embedded icons problem addressed here. In current version only needed to remove all query strings from fonts definitions in css.
4. Weird problem with weinre, it just eaten up all http requests, you can see them in console  but after they don't received by application, have to remove weinre script from app.
5. Disable bouncy scrolling for container
   // Constructor
        public MainPage()
        {
            InitializeComponent();
            this.CordovaView.Loaded += CordovaView_Loaded;
            this.CordovaView.DisableBouncyScrolling = true;
        }
or in MainPage.xaml
  <my:CordovaView DisableBouncyScrolling = true; 
or (prferred) config.xml
<preference name="DisableBouncyScrolling" value="true"/>

Build / Run

1. ionic cordova platform add wp8
2. ionic cordova build wp8
3. Update MainPage.xml if still didn't.
4. Open VS run Device button (phone must be connected, registered and lock screen unlocked)

Environment

VS 2013 Update 3, WP 8.1, cordova 3.6.3-0.2.13, ionic 1.1.9, weinre  2.0.0-pre-HZO3BMNG