[TITANIUM]的Intent與Notification

原本想要實現的事情很簡單,就是收到asp server端的push後,app自己做一個Intent放進Notification後丟出去,然後使用者按下Notification的通知後,在app的webView中打開預先存在Intent中的網址。
事前GCM跟asp的準備當然要先搞定。然後開始準備來存取Intent物件。

第一個先嘗試用putExtra:

Ti.Android.currentActivity.addEventListener('resumed',function(e){
 var intent = Titanium.Android.currentActivity.getIntent();
 var _url = intent.getStringExtra("gotoURL");
//$.webview.url = _url;
});
var intent = Ti.Android.createIntent({
 action : Ti.Android.ACTION_MAIN,
 className : 'tw.idv.Justflyctivity',
 flags : Ti.Android.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Ti.Android.FLAG_ACTIVITY_SINGLE_TOP
});
intent.putExtra("gotoURL","http://justfly.idv.tw");
intent.addCategory(Ti.Android.CATEGORY_LAUNCHER);			    
 
var pending = Ti.Android.createPendingIntent({
 intent : intent,
 type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,
 flags : Ti.Android.FLAG_ACTIVITY_NO_HISTORY
});
 
var notification = Titanium.Android.createNotification({
 icon: Ti.App.Android.R.drawable.notification_icon,
 contentIntent : pending,
 contentTitle : e.data.title,
 contentText : _message[0],
 tickerText: _message[0],
 flags:Titanium.Android.ACTION_DEFAULT | Titanium.Android.FLAG_AUTO_CANCEL | Titanium.Android.FLAG_SHOW_LIGHTS
});
 
Titanium.Android.NotificationManager.notify(1, notification);

然後發現不管再怎麼試,_url都沒有東西。
繼續閱讀

[EC2]用node.js存取mysql

除了能取出資料外,轉成json來處理當然會比較方便嚕。所以首先檢查一下node.js的最新版本,升級後再安裝node-mysqlJSON-js

# wget http://nodejs.org/dist/v0.8.11/node-v0.8.11.tar.gz
# tar zxvf node-v0.8.11.tar.gz
# cd node-v0.8.11
# ./configure
# make
# make install
# which node
/usr/bin/node
# node -v
v0.8.11
# which npm
/usr/bin/npm
# npm -v
1.1.62
# npm install socket.io

接著就找個資料夾建立index.js:
繼續閱讀

[ios6]xcode更新跟iphone5的螢幕大小問題

不曉得事不是由於xcode更新到了4.5.1,今天要用git的時候突然就不能用了@@(git: command not found)
查了一下才發現也是有人跟我有相同的問題,於是打開xcode安裝完「Command Line Tools」後,打完收工!

至於另一個更麻煩的就是iphone5的加長型螢幕了!
繼續閱讀