RetroWeb ~iPhoneとAndroidでハイブリッドゲームアプリ開発~

AIR for iOS+AndroidでSmartPhone Game ハイブリッドアプリ開発

最近作ったアプリ
100億本の抜け毛 100億匹のモナー DQ3闘技場アプリ モナーペット(進化)

ハイブリッドローカル通知を実装しました

「スタミナが満タンになりました!」とかで使うアレです。

AndroidiPhoneともに動きました。iOSならなんと喋ります。
なんという無駄な通知w

f:id:hisashi_vc:20140225201847j:plain

ソースはこんな感じです

import com.juankpro.ane.localnotif.NotificationManager;
import com.juankpro.ane.localnotif.Notification;

const _LOCAL_NOTIFICATION_CODE_001:String = "NOTIFICATION_CODE_SORATOBU_SIMAMURA_001";
const _NOTICE_SOUND_PATH:String = "notice_vo_simamura.wav";//AIR for iOS設定で、含めるファイルに追加する

setLocalNotification(
	"しまむらくん", 
	"「このセーター、しまむらで買ったんだ」", 
	3, 
	_LOCAL_NOTIFICATION_CODE_001,
	_NOTICE_SOUND_PATH
);

function setLocalNotification(title:String, msg:String, sec:int, notificationCode:String, soundName:String):void{
	if(NotificationManager.isSupported){
		var notification:Notification = new Notification();
		
		notification.actionLabel = 
		notification.title = title;//"しまむらくん";
		notification.body = //"このセーター、しまむらで買ったんだ";
		notification.tickerText = msg;//"スタミナが全快になりました!";//上にピロっと出るメッセージ
		
		notification.fireDate = new Date();
		notification.fireDate.seconds += sec;		
		notification.numberAnnotation = 1;
		notification.vibrate = true;
		if(soundName){
			notification.soundName = soundName;
		}
		var m:NotificationManager = new NotificationManager();
		removeLocalNotification(notificationCode, m);
		m.notifyUser(notificationCode, notification);
	}
}

function removeLocalNotification(notificationCode:String, m:NotificationManager=null):void{
	if(NotificationManager.isSupported){
		if(!m){
			m = new NotificationManager();
		}
		m.cancel(notificationCode);
	}
}