working on it ...

Filters

Explore Public Snippets

Sort by

Found 100 snippets matching: ios8

    public by marksimon232  4382  0  6  2

    Xcode 6 - Language options to create the project using swift ios 8 application development? Default Objective C?

    I heard lot of questions asking From xcode 6, when using the menu File -> new -> project -> application
    , it always creates the project using objective C.  what is the option to create the project using swift?
    
    This is the answer of your question:
    
    There is an option to change the language 
    to Swift. It’s on the next page after you select your project type. 
    
    See the snap here:
    http://tinypic.com/r/2pzbtrb/8
    
    Read more:
    http://www.agileinfoways.com/technical-expertise/mobile-applications-development/iphone/
    

    public by marksimon232  4306  1  7  1

    Swift Collections: Create UIAlertViews in Swift (iOS 8)

    This is how you make an alert popup on your iPhone application.
    For beginners UIAlertViews were, on iOS 7, one of the main ways that iOS Developers had to 
    let the app users know something important about the application and its 
    current state. UIActionSheet was sort of the same thing, but with more 
    action-based focus, prompting the user to do something.
    
    On iOS 8 these two classes have been merged into one, called UIAlertController.
    We can display a message to the user doing the following:
    
    ----------------
    var alert = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
    self.presentViewController(alert, animated: true, completion: nil)
    ----------------
    
    That will display a message to the user, but with no buttons so the user can take any action. Also, note that the constructor for the UIAlertController object accepts a preferredStyle param, which can be anyone of the following:
    
    .Alert: shows the message to the user at the center of the screen.
    .ActionSheet: shows the message to the user at the bottom of the screen.
    
    => Actions
    So far we’ve showed the user a message, but we haven’t provided them a way
    to give feedback to us. Enter UIAlertAction. This class has a closure-based 
    syntax and allows us to add buttons to a UIAlertController object, and 
    define what should happen when the user taps that button.
    
    ----------------
    var alert = ....
    
    alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: {(action: UIAlertAction!) in
    
    // What happens when the user taps 'Ok'? That goes in here
    
    }))
    
    self.presentViewController(alert, animated: true, completion: nil)
    ----------------
    
    The UIAlertAction constructor accepts three params: a title (String), a 
    style (UIAlertActionStyle) and a handle (a closure). The style of the 
    UIAlertAction object can be anyone of the following:
    
    .Destructive: renders the title property on red
    .Default
    .Cancel
    
    We can add as many UIAlertActions to a UIAlertController as we want, just be careful not to give your users too many options. Keep things simple.

    external by designerJordan  125  0  2  0

    HLS Alternate Audio Tracks - iOS7 vs. iOS8

    HLS Alternate Audio Tracks - iOS7 vs. iOS8: HLS-alt-audio-iOS8.md
    # Changes to HLS Alternate Audio Tracks
    **iOS7 vs. iOS8**
    
    Since iOS 8 went live on Friday and I updated a few of my devices over the weekend, I decided to do some quick testing of web video playback. Wanted to see if there were any little, undocumented changes that would affect REPlayer, or our general approach to HTML video - like the changes to exiting fullscreen video that came in the update from iOS6->iOS7<sup>[1](#1)</sup>.
    
    Overall, things seem pretty much the same between iOS7->iOS8, and in a quick runthrough, REPlayer looks to be working just fine.
    
    One interesting change to note though, is that the native interface (iOS default controls used when video is fullscreen) for selecting Sub-Title/CC tracks - or Alternate Audio tracks when they're available -  no longer seems to recognize/display the audio tracks in iOS8.
    
    Sub-Title selection still works just fine, but the Audio Section (and Audio Tracks) do not display in iOS8. Confirmed that the testing m3u8 still contains Alternate Audio tracks in the manifest. Viewing the same video on a device running iOS7 will display, and allow the selection of, both Sub-Title and Audio Tracks, while iOS8 will only display the subtitle tracks.
    
    Off the bat, I'm assuming this is a bug, not a feature, and it will be addressed in future updates, though it could also be a result of the transition from QTKit to AVFoundation as the new iOS Media Framework<sup>[2](#2)</sup>. One other possible cause for the discrepancy, is the different versions of WebKit used between the two<sup>[3](#3)</sup>.
    
    ----
    
    ##### Notes and non sequiturs
    
    
    <h6 id="1">1</h6>
    <small>**In iOS6** - when you switched to fullscreen video, there were 2 options available for exiting fullscreen:
    * One was to tap the "Exit Fullscreen" icon in the lower right side of the control bar (Two arrows on a diagonal that were pointing inwards towards each other - the inverse of the icon used to enter fullscreen)
      * This would exit fullscreen, and maintain the current playback state of the video, i.e., if the video was playing in fullscreen, it would continue to be playing after leaving fullscreen - if the video was paused in fullscreen, it would remain paused after leaving fullscreen
    * The other was to tap on the text-button "DONE" in the upper left of the fullscreen interface
      * This would exit fullscreen and pause the video, regardless of current playback state 
    
    **In iOS7** - the "Exit Fullscreen" icon was removed, and the only option was to use "DONE" - this meant that whenever you exited fullscreen in iOS7, the video would be paused every time. Meaning that an extra tap on the Play Button was necessary in order to resume playback.</small>
    
    <h6 id="2">2</h6>
    <small>AVFoundation was added in iOS 7 and existed alongside QTKit, though developers were strongly encouraged to make the switch - Have not yet found explicit documentation of the status/availability of QTKit in iOS8</small>
    
    <h6 id="3">3</h6>
    <small>
    * User Agent String of an iPhone 5S running iOS __8.0__ reports WebKit _v600.1.4_
      * Full User Agent String -  
        `Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12A365 Safari/600.1.4`  
    
    * User Agent String of an iPhone 5S running iOS __7.1__ reports WebKit _v537.51.2_
      * Full User Agent String -  
        `Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D167 Safari/9537.53`</small>
    
    

    external by sfeather  102  0  2  0

    Updated urban airport for tisdk 3.4+ and ios8

    Updated urban airport for tisdk 3.4+ and ios8: urbanairport.js
    // Classic Titanium compatibility
    var _ = _ || require((typeof ENV_TEST === 'boolean') ? 'alloy' : 'underscore')._,
        OS_IOS = Ti.Platform.name === 'iPhone OS',
        OS_ANDROID = (!OS_IOS && Ti.Platform.name === 'android');
    
    // Actual module we're going to extend
    var urbanairship = require('ti.urbanairship');
    
    var callback,
        sound = true,
        debug = (typeof ENV_PRODUCTION === 'boolean' ? !ENV_PRODUCTION : false);
    
    // Android-only vars
    if (OS_ANDROID) {
        var pendingTags = null,
            pendingAlias = null,
            compatibility = false,
            compatibilityStack = [],
            vibrate = true;
    }
    
    // iOS-only vars
    if (OS_IOS) {
        var alert = true,
            badge = true;
    }
    
    urbanairship.register = function(config) {
    
        if (config) {
            this.config(config);
        }
    
        this.enable();
    
        return this;
    };
    
    urbanairship.config = function(config) {
    
        if (debug || config.debug !== false) {
            logger('INIT', config);
        }
    
        var that = this;
    
        _.each(config, function(val, key) {
    
            switch (key) {
    
                // callback
                case 'callback':
                    callback = val;
                    break;
    
                    // debug
                case 'debug':
                    debug = !!val;
                    break;
    
                    // compatibility
                case 'compatibility':
    
                    if (OS_ANDROID) {
                        compatibility = !!val;
    
                        if (typeof config.showOnAppClick === 'undefined') {
                            that.showOnAppClick = compatibility;
                        }
                    }
    
                    break;
    
                    // iOS-only so maybe better always use config file
                case 'options':
    
                    if (OS_IOS) {
                        that.options = val;
                    }
    
                    break;
    
                    // Smart methods
    
                case 'tags':
                    that.resetTags(val);
                    break;
    
                case 'alias':
                    that.resetAlias(val);
                    break;
    
                    // Used for enabling push options
    
                case 'sound':
                    sound = !!val;
                    break;
    
                case 'vibrate':
    
                    if (OS_ANDROID) {
                        vibrate = !!val;
                    }
    
                    break;
    
                case 'badge':
    
                    if (OS_IOS) {
                        badge = !!val;
                    }
    
                    break;
    
                case 'alert':
    
                    if (OS_IOS) {
                        alert = !!val;
                    }
    
                    break;
    
                    // Allows to set pretty much any property or method
                default:
    
                    if (typeof that[key] !== 'undefined') {
    
                        if (_.isFunction(that[key])) {
                            that[key](val);
                            logger('calling ' + key, val);
    
                        } else {
                            that[key] = val;
                            logger('setting ' + key, val);
                        }
                    }
    
                    break;
            }
        });
    };
    
    urbanairship.resetTags = function(tags) {
    
        // We accept a single string as well
        if (typeof tags === 'string') {
            tags = [tags];
        }
    
        // We need to be flying on Android
        if (OS_ANDROID && !this.isFlying) {
            pendingTags = tags;
            return;
        }
    
        this.tags = tags;
    
        return this;
    };
    
    urbanairship.addTags = function(tags) {
    
        // We accept a single string as well
        if (typeof tags === 'string') {
            tags = [tags];
        }
    
        // We need to be flying on Android
        if (OS_ANDROID && !this.isFlying) {
            pendingTags = _.union(pendingTags || [], tags);
            return;
        }
    
        this.tags = _.union(this.tags || [], tags);
    
        return this;
    };
    
    urbanairship.removeTags = function(tags) {
    
        // We accept a single string as well
        if (typeof tags === 'string') {
            tags = [tags];
        }
    
        // We need to be flying on Android
        if (OS_ANDROID && !this.isFlying) {
            pendingTags = _.difference(pendingTags || [], tags);
            return;
        }
    
        this.tags = _.difference(this.tags || [], tags);
    
        return this;
    };
    
    urbanairship.resetAlias = function(alias) {
    
        // We need to be flying on Android
        if (OS_ANDROID && !this.isFlying) {
            pendingAlias = alias;
            return;
        }
    
        this.alias = alias;
    
        return this;
    };
    
    urbanairship.enable = function() {
        var that = this;
    
        if (OS_IOS) {
            var types = [];
    
            if (badge) {
                if (Alloy.Globals.isIOS8Plus) {
                    types.push(Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE);
                } else {
                    types.push(Ti.Network.NOTIFICATION_TYPE_BADGE);
                }
            }
    
            if (alert) {
                if (Alloy.Globals.isIOS8Plus) {
                    types.push(Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT);
                } else {
                    types.push(Ti.Network.NOTIFICATION_TYPE_ALERT);
                }
            }
    
            if (sound) {
                if (Alloy.Globals.isIOS8Plus) {
                    types.push(Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND);
                } else {
                    types.push(Ti.Network.NOTIFICATION_TYPE_SOUND);
                }
            }
    
            if (Alloy.Globals.isIOS8Plus) {
                console.error('-------- is iOS 8 ----------')
    
                Ti.App.iOS.addEventListener('usernotificationsettings', e = function() {
                    Ti.App.iOS.removeEventListener('usernotificationsettings', e);
                    Ti.Network.registerForPushNotifications({
                        success: function(e) {
                            logger('SUCCESS', e);
    
                            that.registerDevice(e.deviceToken);
    
                            e.type = 'success';
    
                            // Android-like args
                            e.valid = e.success;
    
                            caller(e);
                        },
                        error: function(e) {
                            logger('ERROR', e);
    
                            e.type = 'error';
    
                            // Android-like args
                            e.valid = e.success;
    
                            caller(e);
                        },
                        callback: function(e) {
                            logger('CALLBACK', e);
    
                            that.handleNotification(e.data);
    
                            e.type = 'callback';
    
                            // Android-like args
                            e.clicked = e.inBackground;
                            e.message = e.data.aps.alert;
                            e.payload = e.data.aps;
    
                            caller(e);
                        }
                    });
                });
    
                Ti.App.iOS.registerUserNotificationSettings({
                    types: types
                });
            } else {
                Ti.Network.registerForPushNotifications({
                    types: types,
    
                    success: function(e) {
                        logger('SUCCESS', e);
    
                        that.registerDevice(e.deviceToken);
    
                        e.type = 'success';
    
                        // Android-like args
                        e.valid = e.success;
    
                        caller(e);
                    },
    
                    error: function(e) {
                        logger('ERROR', e);
    
                        e.type = 'error';
    
                        // Android-like args
                        e.valid = e.success;
    
                        caller(e);
                    },
    
                    callback: function(e) {
                        logger('CALLBACK', e);
    
                        that.handleNotification(e.data);
    
                        e.type = 'callback';
    
                        // Android-like args
                        e.clicked = e.inBackground;
                        e.message = e.data.aps.alert;
                        e.payload = e.data.aps;
    
                        caller(e);
                    }
                });
            }
    
    
    
        }
    
        if (OS_ANDROID) {
            that.pushEnabled = true;
        }
    
        return this;
    };
    
    urbanairship.disable = function() {
    
        if (OS_IOS) {
            this.unregisterDevice();
        }
    
        if (OS_ANDROID) {
            this.pushEnabled = false;
        }
    
        return this;
    };
    
    if (OS_ANDROID) {
    
        urbanairship.addEventListener(urbanairship.EVENT_URBAN_AIRSHIP_SUCCESS, function(e) {
            logger('SUCCESS', e);
    
            if (pendingAlias !== null) {
                urbanairship.alias = pendingAlias;
                pendingAlias = null;
            }
    
            if (pendingTags !== null) {
                urbanairship.tags = pendingTags;
                pendingTags = null;
            }
    
            e.type = 'success';
    
            // iOS-like args
            e.success = e.valid;
    
            caller(e);
        });
    
        urbanairship.addEventListener(urbanairship.EVENT_URBAN_AIRSHIP_ERROR, function(e) {
            logger('ERROR', e);
    
            e.type = 'error';
    
            // iOS-like args
            e.success = e.valid;
    
            caller(e);
        });
    
        urbanairship.addEventListener(urbanairship.EVENT_URBAN_AIRSHIP_CALLBACK, function(e) {
            logger('CALLBACK', e);
    
            // Make sure we don't call the same notification twice
            if (compatibility) {
                var hash = Ti.Utils.sha1(JSON.stringify([e.payload, e.message]));
    
                if (compatibilityStack.indexOf(hash) !== -1) {
                    return;
                }
    
                compatibilityStack.push(hash);
            }
    
            e.type = 'callback';
    
            // Convert payload via JSON to object
            if (e.payload) {
                try {
                    var json = e.payload.replace(/\{/g, '{"').replace(/=/g, '":"').replace(/, /g, '","').replace(/\}/g, '"}');
                    e.payload = JSON.parse(json);
                } catch (err) {
                    logger('CALLBACK PAYLOAD', err, 'error');
                    e.payload = {};
                }
            }
    
            // iOS-like args
            e.inBackground = null;
            e.data = e.payload || {};
            e.data.alert = e.message;
            e.data.aps = e.data;
    
            caller(e);
        });
    }
    
    function logger(label, data, level) {
    
        if (!level) {
            level = 'debug';
        }
    
        // No DRY code due to https://github.com/dbankier/TiShadow/issues/147
        if (level === 'debug') {
            Ti.API.debug('[URBANAIRPORT] ' + label + (data ? ': ' + JSON.stringify(data, null, '\t') : ''));
        } else {
            Ti.API.error('[URBANAIRPORT] ' + label + (data ? ': ' + JSON.stringify(data, null, '\t') : ''));
        }
    }
    
    function caller(e) {
    
        if (_.isFunction(callback)) {
            callback(e);
        }
    }
    
    module.exports = urbanairship;
    
    

    external by mickobrien99  92  0  1  0

    pushpligin for ios8

    pushpligin for ios8: gistfile1.txt
    /*
     Copyright 2009-2011 Urban Airship Inc. All rights reserved.
    
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
    
     1. Redistributions of source code must retain the above copyright notice, this
     list of conditions and the following disclaimer.
    
     2. Redistributions in binaryform must reproduce the above copyright notice,
     this list of conditions and the following disclaimer in the documentation
     and/or other materials provided withthe distribution.
    
     THIS SOFTWARE IS PROVIDED BY THE URBAN AIRSHIP INC``AS IS'' AND ANY EXPRESS OR
     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
     EVENT SHALL URBAN AIRSHIP INC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    #import "PushPlugin.h"
    
    @implementation PushPlugin
    
    @synthesize notificationMessage;
    @synthesize isInline;
    
    @synthesize callbackId;
    @synthesize notificationCallbackId;
    @synthesize callback;
    
    
    - (void)unregister:(CDVInvokedUrlCommand*)command;
    {
    	self.callbackId = command.callbackId;
    
        [[UIApplication sharedApplication] unregisterForRemoteNotifications];
        [self successWithMessage:@"unregistered"];
    }
    
    - (void)register:(CDVInvokedUrlCommand*)command;
    {
    	self.callbackId = command.callbackId;
    
        NSMutableDictionary* options = [command.arguments objectAtIndex:0];
    
        UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeNone;
    
        id badgeArg = [options objectForKey:@"badge"];
        id soundArg = [options objectForKey:@"sound"];
        id alertArg = [options objectForKey:@"alert"];
    
        if ([badgeArg isKindOfClass:[NSString class]])
        {
            if ([badgeArg isEqualToString:@"true"]) {
                notificationTypes |= UIRemoteNotificationTypeBadge;
            }
        }
        else if ([badgeArg boolValue]) {
            notificationTypes |= UIRemoteNotificationTypeBadge;
        }
    
        if ([soundArg isKindOfClass:[NSString class]])
        {
            if ([soundArg isEqualToString:@"true"]) {
                notificationTypes |= UIRemoteNotificationTypeSound;
        }
        }
        else if ([soundArg boolValue]) {
            notificationTypes |= UIRemoteNotificationTypeSound;
        }
    
        if ([alertArg isKindOfClass:[NSString class]])
        {
            if ([alertArg isEqualToString:@"true"]) {
                notificationTypes |= UIRemoteNotificationTypeAlert;
        }
        }
        else if ([alertArg boolValue]) {
            notificationTypes |= UIRemoteNotificationTypeAlert;
        }
    
    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
    
        UIUserNotificationType UserNotificationTypes = UIUserNotificationTypeNone;
    
        if ([badgeArg isKindOfClass:[NSString class]])
        {
            if ([badgeArg isEqualToString:@"true"]) {
                UserNotificationTypes |= UIUserNotificationTypeBadge;
            }
        }
        else if ([badgeArg boolValue]) {
            UserNotificationTypes |= UIUserNotificationTypeBadge;
        }
    
        if ([soundArg isKindOfClass:[NSString class]])
        {
            if ([soundArg isEqualToString:@"true"]) {
                UserNotificationTypes |= UIUserNotificationTypeSound;
            }
        }
        else if ([soundArg boolValue]) {
            UserNotificationTypes |= UIUserNotificationTypeSound;
        }
    
        if ([alertArg isKindOfClass:[NSString class]])
        {
            if ([alertArg isEqualToString:@"true"]) {
                UserNotificationTypes |= UIUserNotificationTypeAlert;
            }
        }
        else if ([alertArg boolValue]) {
            UserNotificationTypes |= UIUserNotificationTypeAlert;
        }
    
        notificationTypes |= UIRemoteNotificationTypeNewsstandContentAvailability;
        UserNotificationTypes |= UIUserNotificationActivationModeBackground;
    
       #endif
     if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
     {
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UserNotificationTypes categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
     }else{
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         UIRemoteNotificationTypeBadge |
         UIRemoteNotificationTypeAlert |
         UIRemoteNotificationTypeSound];
     }
    
    
        self.callback = [options objectForKey:@"ecb"];
    
        if (notificationTypes == UIRemoteNotificationTypeNone)
            NSLog(@"PushPlugin.register: Push notification type is set to none");
    
        isInline = NO;
    
    	if (notificationMessage)			// if there is a pending startup notification
    		[self notificationReceived];	// go ahead and process it
    }
    
    /*
    - (void)isEnabled:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options {
        UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
        NSString *jsStatement = [NSString stringWithFormat:@"navigator.PushPlugin.isEnabled = %d;", type != UIRemoteNotificationTypeNone];
        NSLog(@"JSStatement %@",jsStatement);
    }
    */
    
    - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    
        NSMutableDictionary *results = [NSMutableDictionary dictionary];
        NSString *token = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""]
                            stringByReplacingOccurrencesOfString:@">" withString:@""]
                           stringByReplacingOccurrencesOfString: @" " withString: @""];
        [results setValue:token forKey:@"deviceToken"];
    
        #if !TARGET_IPHONE_SIMULATOR
            // Get Bundle Info for Remote Registration (handy if you have more than one app)
            [results setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"] forKey:@"appName"];
            [results setValue:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"appVersion"];
    
            // Check what Notifications the user has turned on.  We registered for all three, but they may have manually disabled some or all of them.
            NSUInteger rntypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
    
            // Set the defaults to disabled unless we find otherwise...
            NSString *pushBadge = @"disabled";
            NSString *pushAlert = @"disabled";
            NSString *pushSound = @"disabled";
    
            // Check what Registered Types are turned on. This is a bit tricky since if two are enabled, and one is off, it will return a number 2... not telling you which
            // one is actually disabled. So we are literally checking to see if rnTypes matches what is turned on, instead of by number. The "tricky" part is that the
            // single notification types will only match if they are the ONLY one enabled.  Likewise, when we are checking for a pair of notifications, it will only be
            // true if those two notifications are on.  This is why the code is written this way
            if(rntypes & UIRemoteNotificationTypeBadge){
                pushBadge = @"enabled";
            }
            if(rntypes & UIRemoteNotificationTypeAlert) {
                pushAlert = @"enabled";
            }
            if(rntypes & UIRemoteNotificationTypeSound) {
                pushSound = @"enabled";
            }
    
            [results setValue:pushBadge forKey:@"pushBadge"];
            [results setValue:pushAlert forKey:@"pushAlert"];
            [results setValue:pushSound forKey:@"pushSound"];
    
            // Get the users Device Model, Display Name, Token & Version Number
            UIDevice *dev = [UIDevice currentDevice];
            [results setValue:dev.name forKey:@"deviceName"];
            [results setValue:dev.model forKey:@"deviceModel"];
            [results setValue:dev.systemVersion forKey:@"deviceSystemVersion"];
    
    		[self successWithMessage:[NSString stringWithFormat:@"%@", token]];
        #endif
    }
    
    - (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
    {
    	[self failWithMessage:@"" withError:error];
    }
    
    - (void)notificationReceived {
        NSLog(@"Notification received");
    
        if (notificationMessage && self.callback)
        {
            NSMutableString *jsonStr = [NSMutableString stringWithString:@"{"];
    
            [self parseDictionary:notificationMessage intoJSON:jsonStr];
    
            if (isInline)
            {
                [jsonStr appendFormat:@"foreground:\"%d\"", 1];
                isInline = NO;
            }
    		else
                [jsonStr appendFormat:@"foreground:\"%d\"", 0];
    
            [jsonStr appendString:@"}"];
    
            NSLog(@"Msg: %@", jsonStr);
    
            NSString * jsCallBack = [NSString stringWithFormat:@"%@(%@);", self.callback, jsonStr];
            [self.webView stringByEvaluatingJavaScriptFromString:jsCallBack];
    
            self.notificationMessage = nil;
        }
    }
    
    // reentrant method to drill down and surface all sub-dictionaries' key/value pairs into the top level json
    -(void)parseDictionary:(NSDictionary *)inDictionary intoJSON:(NSMutableString *)jsonString
    {
        NSArray         *keys = [inDictionary allKeys];
        NSString        *key;
    
        for (key in keys)
        {
            id thisObject = [inDictionary objectForKey:key];
    
            if ([thisObject isKindOfClass:[NSDictionary class]])
                [self parseDictionary:thisObject intoJSON:jsonString];
            else if ([thisObject isKindOfClass:[NSString class]])
                 [jsonString appendFormat:@"\"%@\":\"%@\",",
                  key,
                  [[[[inDictionary objectForKey:key]
                    stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"]
                     stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]
                     stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"]];
            else {
                [jsonString appendFormat:@"\"%@\":\"%@\",", key, [inDictionary objectForKey:key]];
            }
        }
    }
    
    - (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
    
        self.callbackId = command.callbackId;
    
        NSMutableDictionary* options = [command.arguments objectAtIndex:0];
        int badge = [[options objectForKey:@"badge"] intValue] ?: 0;
    
        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge];
    
        [self successWithMessage:[NSString stringWithFormat:@"app badge count set to %d", badge]];
    }
    -(void)successWithMessage:(NSString *)message
    {
        if (self.callbackId != nil)
        {
            CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
            [self.commandDelegate sendPluginResult:commandResult callbackId:self.callbackId];
        }
    }
    
    -(void)failWithMessage:(NSString *)message withError:(NSError *)error
    {
        NSString        *errorMessage = (error) ? [NSString stringWithFormat:@"%@ - %@", message, [error localizedDescription]] : message;
        CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMessage];
    
        [self.commandDelegate sendPluginResult:commandResult callbackId:self.callbackId];
    }
    
    @end
    
    

    external by rpavez  80  0  1  0

    BasicGeo with iOS8 locationServicesAuthorization

    BasicGeo with iOS8 locationServicesAuthorization : backgroundLocationIOS.js
    var basicgeo = require("bencoding.basicgeo");
    var available = basicgeo.createAvailability();
    
    
    function sendLocation(location) {
    	/*
    	xhr.send({
    		latitude : location.coords.latitude,
    		longitude : location.coords.longitude
    	});
    	*/
    }
    
    //Define our location monitor object
    var locationMonitor = {
    	module : null,
    	errorEvt : function(e) {
    		Ti.API.info("Location Monitor Error " + JSON.stringify(e));
    	},
    	changeEvt : function(e) {
    		Ti.API.info("ChangeEvt!\n"+JSON.stringify(e));
    		sendLocation(e);
    	},
    	startEvt : function(e) {
    		Ti.API.info("Monitor startEvt");
    	},
    	stopEvt : function(e) {
    		Ti.API.info("Monitor stopEvt");
    	},
    	timerEvt : function(e) {
    		Ti.API.info("Timer fired!");
    	},
    	start : function() {
    		//First we start everything up
    		if (locationMonitor.module == null) {
    			locationMonitor.module = require("bencoding.basicgeo").createLocationMonitor();
    			locationMonitor.module.addEventListener('error', locationMonitor.errorEvt);
    			locationMonitor.module.addEventListener('start', locationMonitor.startEvt);
    			locationMonitor.module.addEventListener('stop', locationMonitor.stopEvt);
    			locationMonitor.module.addEventListener('change', locationMonitor.changeEvt);
    			locationMonitor.module.addEventListener('timerFired', locationMonitor.timerEvt);
    			Ti.API.info('Location Monitor Listeners Added');
    		}
    		//Add our configuration parameters
    		locationMonitor.module.purpose = "GSP Purpose";
    		locationMonitor.module.staleLimit = 5;
    		locationMonitor.module.accuracy = Ti.Geolocation.ACCURACY_LOW;
    		locationMonitor.module.distanceFilter = 300;
    
    		//Start monitoring for changes
    		locationMonitor.module.startMonitoring();
    	},
    	stop : function() {
    		if (locationMonitor.module != null) {
    			locationMonitor.module.stopMonitoring();
    			Ti.API.info('locationMonitor Stopped');
    			locationMonitor.module.removeEventListener('error', locationMonitor.errorEvt);
    			locationMonitor.module.removeEventListener('start', locationMonitor.startEvt);
    			locationMonitor.module.removeEventListener('stop', locationMonitor.stopEvt);
    			locationMonitor.module.removeEventListener('change', locationMonitor.changeEvt);
    			locationMonitor.module.removeEventListener('timerFired', locationMonitor.timerEvt);
    			Ti.API.info('locationMonitor Listeners Removed');
    			locationMonitor.module = null;
    		}
    	}
    };
    
    gpsAuthStarted = false;
    
    function gpsAuthorized(){
    	alert(printAuthorizedResults(Ti.Geolocation.locationServicesAuthorization));
    	locationMonitor.start();
    };
    
    setInterval(function(){
    	if(Ti.Geolocation.locationServicesAuthorization == Ti.Geolocation.AUTHORIZATION_ALWAYS && !gpsAuthStarted) 
    	{
    		gpsAuthStarted = true;
    		gpsAuthorized();
    	}
    },500);
    
    setTimeout(function() {
    	if(Ti.Geolocation.locationServicesAuthorization != Ti.Geolocation.AUTHORIZATION_ALWAYS)
    	{ Ti.Geolocation.requestAuthorization(Titanium.Geolocation.AUTHORIZATION_ALWAYS); }
    }, 500); 
    
    

    external by buguibu  80  0  1  0

    Table cell separators no left margin iOS8

    Table cell separators no left margin iOS8: cell_no_left_margin_ios8
    -(void)viewDidLayoutSubviews
    {
        if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
            [self.tableView setSeparatorInset:UIEdgeInsetsZero];
        }
        
        if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
            [self.tableView setLayoutMargins:UIEdgeInsetsZero];
        }
    }
    
    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
            [cell setSeparatorInset:UIEdgeInsetsZero];
        }
        
        if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
            [cell setLayoutMargins:UIEdgeInsetsZero];
        }
    }
    
    

    external by Johan Hernandez  68  0  1  0

    Fix iOS8 UI datepicker issue.

    Fix iOS8 UI datepicker issue.: fix_ios8_datepicker.mm
    // https://medium.com/@bithavoc/uidatepicker-presentation-issue-on-ios-8-98215118a27f
    
    if(NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) {
      [[UITableView appearanceWhenContainedIn:[UIDatePicker class], nil] setBackgroundColor:nil]; // for iOS 8
    } else {
      [[UITableViewCell appearanceWhenContainedIn:[UIDatePicker class], [UITableView class], nil] setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.0]]; // for iOS 7
    }
    
    

    external by billdonner  57  1  1  0

    Make IOS8 Icon Set From Single PNG

    Make IOS8 Icon Set From Single PNG: micon.sh
    #!/bin/bash
    # input png is 512 sq
    # IOS8sizes=( 29 40 58  76 80 87 120  152 180 )
    # a better script would loop
    sips --resampleHeightWidth  29 29 $1-512.png --out $1-29.png
    sips --resampleHeightWidth  40 40 $1-512.png --out $1-40.png
    sips --resampleHeightWidth  58 58 $1-512.png --out $1-58.png
    sips --resampleHeightWidth  76 76 $1-512.png --out $1-76.png
    sips --resampleHeightWidth  80 80 $1-512.png --out $1-80.png
    sips --resampleHeightWidth  87 87 $1-512.png --out $1-87.png
    sips --resampleHeightWidth  120 120 $1-512.png --out $1-120.png
    sips --resampleHeightWidth  152 152 $1-512.png --out $1-152.png
    sips --resampleHeightWidth  180 180 $1-512.png --out $1-180.png
    
    
    

    external by Seyhun Akyürek  57  0  1  0

    iOS8 - Webkit

    iOS8 - Webkit: ios_webkit.swift
    import UIKit
    import WebKit
    
    class ViewController: UIViewController {
    
        @IBOutlet var containerView : UIView! = nil
        var webView: WKWebView?
        
        override func viewDidLoad() {
            super.viewDidLoad()
    
            // Do any additional setup after loading the view, typically from a nib.
            
            var url = NSURL(string:"http://pointro.me/users/sign_in")
            var req = NSURLRequest(URL:url!)
            self.webView!.loadRequest(req)
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
        
        override func loadView() {
            super.loadView()
            
            self.webView = WKWebView()
            self.view = self.webView!
        }
    
    }
    
    
    
    
    • Public Snippets
    • Channels Snippets