-
-
Save hansemannn/c6daf98c25fd7635d1cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.App.addEventListener("resume", function(){ | |
Ti.API.info("Resume Event Fired"); | |
}); | |
Ti.App.addEventListener("resumed", function(){ | |
Ti.API.info("Resumed Event Fired"); | |
}); | |
Ti.App.iOS.addEventListener("shortcutitemclick", function(e){ | |
Ti.API.info("shortcutitemclick Event Fired"); | |
Ti.API.info("event payload:" + JSON.stringify(e)); | |
}); | |
var win = Titanium.UI.createWindow({ | |
title:'Test', backgroundColor:'#fff', layout:"vertical" | |
}); | |
var btn1 = Ti.UI.createButton({ | |
top: 50, height:45, title:"Add Contact Us Application Shortcut" | |
}); | |
win.add(btn1); | |
btn1.addEventListener("click",function(){ | |
var appShortcuts = Ti.UI.iOS.createApplicationShortcuts(); | |
appShortcuts.addDynamicShortcut({ | |
itemtype:"contact_us", | |
title:"Contact Us", | |
subtitle:"Tap to reach us", | |
icon: Ti.UI.iOS.SHORTCUT_ICON_TYPE_ADD, | |
userInfo:{ | |
infoKey:"contact_us" | |
} | |
}); | |
}); | |
var btn2 = Ti.UI.createButton({ | |
top: 10, height:45, title:"Remove Contact Us Application Shortcut" | |
}); | |
win.add(btn2); | |
btn2.addEventListener("click",function(){ | |
var appShortcuts = Ti.UI.iOS.createApplicationShortcuts(); | |
appShortcuts.removeDynamicShortcut("contact_us"); | |
}); | |
var btn3 = Ti.UI.createButton({ | |
top: 10, height:45, title:"Count Dynamic App Shortcuts" | |
}); | |
win.add(btn3); | |
btn3.addEventListener("click",function(){ | |
var appShortcuts = Ti.UI.iOS.createApplicationShortcuts(); | |
var shortcuts = appShortcuts.listDynamicShortcuts(); | |
Ti.API.info("Dynamic App Shortcut count:" + shortcuts.length); | |
Ti.API.info("Dynamic App Shortcut as JSON:" + JSON.stringify(shortcuts)); | |
}); | |
var btn4 = Ti.UI.createButton({ | |
top: 10, height:45, title:"Count Static App Shortcuts" | |
}); | |
win.add(btn4); | |
btn4.addEventListener("click",function(){ | |
var appShortcuts = Ti.UI.iOS.createApplicationShortcuts(); | |
var shortcuts = appShortcuts.listStaticShortcuts(); | |
Ti.API.info("Static App Shortcut count:" + shortcuts.length); | |
Ti.API.info("Static App Shortcut as JSON:" + JSON.stringify(shortcuts)); | |
}); | |
var btn5 = Ti.UI.createButton({ | |
top: 10, height:45, title:"Dynamic Shortcut Exists?" | |
}); | |
win.add(btn5); | |
btn5.addEventListener("click",function(){ | |
var appShortcuts = Ti.UI.iOS.createApplicationShortcuts(); | |
var exists = appShortcuts.dynamicShortcutExists("contact_us"); | |
var msg = (exists) ? "Icon exists" : "Sorry isn't there"; | |
alert(msg); | |
}); | |
var btn6 = Ti.UI.createButton({ | |
top: 10, height:45, title:"Remove All Dynamic Shortcuts" | |
}); | |
win.add(btn6); | |
btn6.addEventListener("click",function(){ | |
var appShortcuts = Ti.UI.iOS.createApplicationShortcuts(); | |
appShortcuts.removeAllDynamicShortcuts(); | |
}); | |
var btn7 = Ti.UI.createButton({ | |
top: 10, height:45, title:"Get shortcut by itemtype \"contact_us\"" | |
}); | |
win.add(btn7); | |
btn7.addEventListener("click",function(){ | |
var appShortcuts = Ti.UI.iOS.createApplicationShortcuts(); | |
var shortcut = appShortcuts.getDynamicShortcut("contact_us"); | |
alert(shortcut); | |
}); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment