Skip to content

Instantly share code, notes, and snippets.

@Seasons7
Created August 30, 2011 07:54
Show Gist options
  • Save Seasons7/1180417 to your computer and use it in GitHub Desktop.
Save Seasons7/1180417 to your computer and use it in GitHub Desktop.
OpenReeder
Titanium.UI.setBackgroundColor('#000');
var notification;
var fireDate = null;
var hasNotification = true;
var win = Titanium.UI.createWindow({
title:'OpenReeder',
backgroundColor:'#fff'
});
var button = Ti.UI.createButton({
title:'Setup',
bottom:20,
width:200,
height:40
});
button.addEventListener('click',function(){
hasNotification = true;
Ti.App.iOS.cancelAllLocalNotifications();
notification = Ti.App.iOS.scheduleLocalNotification({
date:fireDate,
//repeat: "daily"
alertBody: "Reederを同期しましょう!!",
alertAction: "Reeder起動",
sound: "default",
userInfo: { app: "reeder:///" }
});
alert( '通知を設定しました' );
});
var minDate = new Date();
minDate.setFullYear(2009);
minDate.setMonth(0);
minDate.setDate(1);
var maxDate = new Date();
maxDate.setFullYear(2020);
maxDate.setMonth(11);
maxDate.setDate(31);
var value = new Date();
var picker = Ti.UI.createPicker({
type:Ti.UI.PICKER_TYPE_DATE_AND_TIME,
minDate:minDate,
maxDate:maxDate,
value:value,
top:0
});
picker.addEventListener('change',function(e)
{
fireDate = e.value;
});
picker.selectionIndicator = true;
win.add( picker );
win.add( button );
var reederURL = 'reeder:///';
Ti.App.iOS.addEventListener("notification", function(e){
Ti.API.log(e.userInfo.app);
Ti.Platform.openURL( reederURL );
});
Ti.App.addEventListener("resume", function(){
if( hasNotification ) {
hasNotification = false;
notification.cancel();
Ti.Platform.openURL( reederURL );
}
});
win.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment