2013年4月29日 星期一

Mobile Backend Services


The Administrator Page on Helios Server

   開發App的同時,需要一些Server的功能來輔助,例如:Bug report、Push Message、In-app-purchase(包含購買即下載的功能)、使用者資料分析(好像有點違法)、雲端記錄檔等等。話說技術上難度並不是太高,反而多的是冗於的重工,又或者API或資料格式定義不好,導致實作的SDK有點難以理解。

通常尋求這類型解答有幾種思考模式:


第一、花錢消災型:多用第三方服務以利於快速達陣,花錢好辦事,問題有人檔,根據以上需求分別有:

Bug report : BugsenseTestFightCrashlytics
Push Message : Parse(最近被Facebook買走了)UrbanAirShip
使用者資料分析:FlurryMixpanel

   這類型服務通常各種平台的SDK都要有,後端的資料儲存有多Big Data就多Big Data,當然好看的後台管理介面同樣只是基本需求,不過每種服務都可以相互跨越、取代(能存使用者資訊當然就能夠存Bug訊息)。

第二、硬幹型:這類型的思考通常覺得,東西是別人的就沒有安全感(怕很客製化的東西沒辦法加上去),不過如果太客製的需求是否代表著這是一個荒謬的需求?

第三、Open Source型:還是有些好心人會把類似的服務包成一個Open Source專案(例如: Helios或者OpenKitOpenKit的前身的OpenFeint),自己就可以架一台Server囉!


2013年4月27日 星期六

Facebook : Login for Desktop Apps



   果想要讓一個小盒子(例如:Embedded System or Raspberry Pi)能夠拿到facebook的access token來做一些事情,例如:控制GPIO顯示未讀訊息(NOTICE : Physical Facebook Notifier)、抓臉書的相片當做數位像框、當關注的異性感情狀態變更時會有鬧鈴提醒等等。

   盒子通常不會有實體IP(而且也不切實際,就算有IP,幫每個盒子都必須申請一個特別的Facebook ID也很噁心),此時就可以使用Desktop版本的登入方式,操作概念如下:

1. 將redirect_url改成 https://www.facebook.com/connect/login_success.html

    https://www.facebook.com/dialog/oauth?
        client_id=YOUR_APP_ID
       &redirect_uri=https://www.facebook.com/connect/login_success.html
       &scope=COMMA_SEPARATED_LIST_OF_PERMISSION_NAMES
       &response_type=token


2. 偵測redirect的event,在把redirect Url上的access token變數拿下來用

https://www.facebook.com/connect/login_success.html#
    access_token=USER_ACCESS_TOKEN...

   偵測的方式可以用WebView掛Listener來完成,看起來還是要提供螢幕讓使用者登入:(,不過之前在hack Google Play Console的API時,有參考Andlytics模仿Google登入的request內容,應該還是有機會辦到純Program的方式拿到access token


----------- 2013/4/29 修正 -------------

看起來NOTICE : Physical Facebook Notifier作法比較簡單,只把七段顯示器直接透過serial port來操作,所有認證的畫面及流程都用桌面軟體搞定。



2013年4月18日 星期四

Test Framework on Android

   In the test case, we can divide into unit and integration test(also call it is white and black box test). we always   use the unit test to make sure the correctness. and integration test to make sure it in user's way. Android provide the framwork's to finish this work:

Test Project : Include the mock object for Android's object, and also test the key objects : Activity and Service. in the other way, it's support emma(the code coverage tool for test case). the usage step show as follow:
  1. android create test-project -m ../MyAndroidProject-n MyTestProject -p MyActivityTest
  2. ant emma debug install test #Run the test case on debug build with code coverage analysis
UI Test : It's new feature in Android SDK 16 and high. it can write the script(Java) to control the UI Components( for example: click button, swipe list view and press the back key). looks like it's not support dragging touch event. the usage step show as follow: 

  1. android create uitest-project -n my_ui_test_project -t 1 -p my_ui_test_project_folder
  2. ant build
  3. adb push bin/my_ui_test_project.jar /usr/local/tmp/
  4. adb shell uiautomator my_ui_test_project.jar -c com.yourtestcasepackagename.app.Main
Monkey : Send bunch of key/touch event into Application.
example : adb shell monkey -p com.yourpakcagename.app -v 50000 (send the number of events)


In the future work, we can integration it into the Jenkins service.


2013年4月3日 星期三

Hack the Google's play store console api




   The feature is not publish in today, but we want to re-design the data visualization on our service. some Third-party service(like AppFigures) can organize it after you offer the play and  app store account, but it has some problem for sync Google account ( you will recv alert for change password ). So we decide to hack the api.

   The android application : Andlytics can handle those data and show it on. but it's hack way, mimic the console from Google's ajax request. so we need to take the two problem : authorization and data parsing.

Authorization : you can reference Developer-Console-v2 (Google say it will update at April 15. 2013 :( ).
Data parsing : the Json format looks like Proguard. so you need to login the console and try to mapping the data with dashboard :((

Future work:
if the Google still without release the API in the short time. i will publish the implementation on Grails framework :)