Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Bahrenburg benbahrenburg

View GitHub Profile
View launch.js
<activities>
<activity android:screenOrientation="portrait"
android:theme="@style/FullHeightDialog" url="Sections/quetiondialog.js"/>
</activities>
View gist:9e676e869236e3191afa
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
@benbahrenburg
benbahrenburg / index.md
Last active Aug 29, 2015
iOS 8 : Local Notification PR Description
View index.md

Adding iOS8 Location Notification Permission Support to Titanium

Before you start, you must make the below changes to Ti SDK 3.4.0 or greater

This gist discusses the approach used to provide a PR for https://jira.appcelerator.org/browse/TC-4671 PR submitted here https://github.com/appcelerator/titanium_mobile/pull/6025

In this gist we will provide step by step instructions and reasons for adding features to Titanium to allow developers to check iOS 8 the current UIUserNotificationSettings for the app. These are needed so the developer can determine if the proper UIUserNotificationType has been granted to their app.

To accomplish this, we first add an event listener to Ti.App.iOS called usernotificationsetting. This will fire when the app's [UIApplication sharedApplication] currentUserNotificationSettings is updated.

View app.js
//This is the app.js you can use for testing
var win = Titanium.UI.createWindow({
backgroundColor:'#fff',layout:'vertical'
});
var btnAuthorization = Titanium.UI.createButton({
title:'Authorization Check', left:25,right:25, top:80
});
win.add(btnAuthorization);
@benbahrenburg
benbahrenburg / read.js
Created Nov 8, 2014
Note Table - Read Script
View read.js
function read(query, user, request) {
query.where({ userId: user.userId });
request.execute();
}
@benbahrenburg
benbahrenburg / delete.js
Last active Aug 29, 2015
Note Table - Delete Script
View delete.js
function del(id, user, request) {
var table = tables.getTable('notes');
table.where({
id: id, userId : user.userId
}).read({
success: delItems
});
function delItems(items) {
if (items.length > 0) {
@benbahrenburg
benbahrenburg / update.js
Last active Aug 29, 2015
Note Table - Update Script
View update.js
function update(item, user, request) {
var table = tables.getTable('notes');
table.where({
id: item.id, userId : user.userId
}).read({
success: upsertItem
});
function upsertItem(items) {
@benbahrenburg
benbahrenburg / insert.js
Last active Aug 29, 2015
Note Table - Insert Script
View insert.js
function insert(item, user, request) {
var table = tables.getTable('notes');
table.where({
id: item.id,
userId : user.userId
}).read({
success: upsertItem
});
function upsertItem(items) {
@benbahrenburg
benbahrenburg / insert.js
Last active Aug 29, 2015
NoteEvents - Insert Script
View insert.js
function insert(item, user, request) {
var table = tables.getTable('noteEvents');
table.where({
id: item.id,
userId :item.userId
}).read({
success: upsertItem
});
@benbahrenburg
benbahrenburg / gist:154c9e16180bd04b9a2f
Last active Aug 29, 2015
NoteEvents - Update Script
View gist:154c9e16180bd04b9a2f
function update(item, user, request) {
var table = tables.getTable('noteEvents');
table.where({
id: item.id,
userId : user.userId
}).read({
success: upsertItem
});