четверг, 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.