Links

APIs introduced in iOS 8

iOS 7 was something big for its designers and now its time for developers. Yes, iOS 8 is really huge for developers with all new Swift, Unified Storyboards, Handoff and so forth.
Some new features of iOS can surely change the way we achieve our business logic, like CloudKit and Cordova can do really amazing work together. With App Extensions now its easy to interact with iOS, Some interesting things we can do with App Extensions:
  1. Sharing for most of data e.g;
    • Audio
    • Video
    • Photos
    • Comments
    • Links
  2. Actions to Transform data
  3. Photo editing in native iOS App
  4. Safari extensions to access and manipulate DOM
  5. Interactive notification center widgets
  6. Document providers to access additional storage
  7. Third party keyboards with more languages and input methods

PFB- A high level idea of new APIs introduced in iOS8;
1) CloudKit
From iOS8+, user can access there files from third party document providers within an app, CloudKit provides APIs to code the same. It is a network depended Cloud access framework for shared cloud storage. Its classes can't be subclassed. Its synchronous and for asynchronous transfers it relies on NSOperation/GCD. Good to know things before starting with iCloud Drive;
  • User can access shared files from Finder in Mac
  • We need to use UIDocumentPicker to access iCloud Drive files in iOS because there is no shared storage app in iOS for it
  • We can manage Records, Relationships and Queries with CKRecord framework and Assets/Larg data blobs with the help of CKAsset framework
  • We can use CKSubscription framework to get notified in case of change in cloud with a cute puch notification
  • We can access the cloud with the help of Developer Portal
  • No need to create user accounts as we can use user's iCloud Account
  • Storage is free, but Apple have reserved the access rights for it to prevent misusage
2) CoreAuthentication
Device owner authentication with/without biometrics (Touch ID - iPhone5S+)
3) HealthKit
Access users health related data managed by Apple Health, i.e; Sex, BloodType etc. Access health accessories sensors reports i.e; Body temperature, Heart rate etc.
4) HomeKit
It provide support to work with Apple's Home Automation Protocol. It will help you Discover, Communicate and Manage the supported accessories.
5) LocalAuthentication
To use Biometrics Authentication (Touch ID - iPhone5S+). It will only tell you if user authenticated successfully or not to take appropriate action.
6) Metal
It provides support for GPU-accelerated (Apple A7+) advanced 3D graphics rendering, precompiled shaders, state objects, explicit command scheduling and data-parallel computation workloads. It works efficiently Metal shading language.
7) NotificationsUI
Used to create an iOS notification centre widget of an app
8) NetworkExtension
Manage virtual private network with IKEv2/IPSec
9) Photos
Access/Observe/Manage the shared photo library available in both Swift and Objective C
  • Direct photo access in native app and iCloud with PHAssetCollection
  • Full manual control on native camera and Bracketed Capture with the help of AVCaptureDevice
10) PhotosUI
Used to create custom view-controller class as an extension which provide a user interface for editing photo or video assets in iOS Photos app.
11) SceneKit
Processing and animating 3D vector-based graphics, It can work together with SpriteKit as well
12) WebKit
It provides an extended web content rendering support with Java, JavaScript and Media Playback configuration.
13) AVKit
Yet another optimised audio video player view-controller
14) CoreAudioKit
Manage inter app audio player controls
15) NotificationCenter
Both a widget and its containing app can use this API to communicate and specify whether there is content in the widget should display or it should be visible in the Today view or its most recent snapshot is still valid, etc.
16) PushKit
---


Apple made its admirers quite busy for next few months, cheers folks :)

Using custom UIFont on the fly

Here is yet another code snippet to add a custom font in UIFonts list without previously adding it in your app.plist file, useful while working with library projects and downloading font on the fly.
    NSArray *arrFont = @[@"Comic Sans MS.ttf",@"Tahoma.ttf"];
    
    for (NSString *str in arrFont) {
        
        NSString *fontPath = [[NSBundle mainBundle] pathForResource:BUNDLE_NAME ofType:@"bundle"];
        
        NSData *inData = [NSData dataWithContentsOfFile:[fontPath stringByAppendingFormat:@"/%@",str]];
        CFErrorRef error;
        CGDataProviderRef provider = CGDataProviderCreateWithCFData((__bridge CFDataRef)inData);
        CGFontRef font = CGFontCreateWithDataProvider(provider);
        
        if (! CTFontManagerRegisterGraphicsFont(font, &error)) {
            CFStringRef errorDescription = CFErrorCopyDescription(error);
            NSLog(@"Failed to load font: %@", errorDescription);
            CFRelease(errorDescription);
        }
        CFRelease(font);
        CFRelease(provider);
    }

Potential security risks in iOS Apps - Part 1

Few days back Apple developer portal hacked by someone, Do we have a leak in our apps? 

In our busy schedule and tight project deadlines we just want to ignore some basic risks in our app, some people think that Apple environment is close enough to take care of it. Do we are really missing something? yes we are..

These risk increases when we use WebServices, keep files in application folders and don't forget to remove logs while deploying in public domain. Root cause of security holes are:


WebServicesPublicly-Accessible filesInsecure database


I am trying to list down basic things that we can keep in mind while coding:
  1. Use NSTemporaryDirectory or confstr 
  2. Use of higher level APIs like NSFileManager aren't safe enough 
  3. Run static analysis tool frequently. It will not give you all possible issues but it can help with some basics.
  4. Use preprocessor directives to identify the debug environment 
  5. Avoid using NSLog, use some user define macro for logging
    #ifdef DEBUGING
              #define Log( s, ... ) NSLog( @" %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
    #else
              #define Log( s, ... )
    #endif
  6. Always log with formatted string, passing ID to log can create a potential leak
  7. Avoid Cross-site scripting
  8. While opening any URL from a web content check if it is a resource path or a link
  9. Avoid PhoneGap based environment while security is a concern 
  10. Don't trust document serialization and avoid directly executing from the same 
  11. Be aware of trojan/code injection every time you process a downloaded file or file from local directories 
  12. Use hardening techniques
  13. Be aware of security properties of APIs you use 

Useful testing stuffs 
  1. Unit-Testing is your friend 
  2. Crash Wrangler - Fuzzing
  3. Penetration testing

Connecting with iOS

I was just wondering that how to connect with an iPhone, iPod and iPad. The outcome of my research is there are three ways:
Dock
Bluetooth
WiFi
An interesting fact is that the antenna for WiFi and Bluetooth is same. To communicate with external accessories there is a ExternalAccessoryFramework.

The architecture of EAF is quite simple, it have a EAProtocol and each span of communication is known as EASession. NSStream helps to carry payload and for input there is NSInputStream and for output there is NSOutputStream

Other core level frameworks like CoreAudio, CoreLocation etc, are also helpful while communicating with an external accessory because they get notification of route change. While we connect or disconnect iOS via dock, EAAccessory notify the app by NSNotificationCenter

  •  EAAccessoryDidConnectNotification
  •  EAAccessoryDidDisconnectNotification


Things to keep in mind
  1. There are no EA events in background we should keep track of application did enter background
  2. Close your EA session as soon as your work is completed 
  3. Antenna arbitration is there
  4. Use accessory change notification generously and be prepared for connectivity loss

Web-Services recapitulate

Now days most of the apps are using WebServices and the good thing is we all know what it is :)

Just adding some notes from my side on things like SOAP, REST and ......., and what? is there anything else do we have in the name of WebService.. really?

Few days ago, a guy who have experience of more then a decade came to me and told me to integrate WebService in an app. I simply asked for WebService summary which I think an usual question while we start working on something. He said to take the reference from an existing website which he pretended that using the same. First I did't get what he wanted to tell but, his steps just gave me heart attack. He just went to Chrome, opened the Website, right clicked for the Inspect element option and while logging in to that website he monitored the Network and said look here is the WebServices just replicate it in your app. After his statement I thought is it worth to ask something anymore?




Okey, letz do a quick recap on what we know:

  1. Charles, Yet simplest tool to monitor a WebService request from an iOS and Mac environment
  2. Each and every resource request to an URI is not a WebService.
  3. One is SOAP and the rest is REST, why do extensive debate
  4. SOAP is XML based definitive object access WebService protocol made for rich guys :)
  5. OAUTH is a two tear authorization framework, ie 

iOS + WS 
  1. Avoid using 3rd party wrappers like ASIHTTP for networking without exploring them
  2. NSURLRequest + NSURLConnection are not an evil
  3. Use event driven APIs
  4. Reachability is our friend
  5. Don't put sync requests on main thread
  6. Your app UI should reflect network reality 
  7. Be prepared for speed latency and packet loss
  8. Be prepared for no network and host not reachable conditions
  9. Always code for insecure connection, use end to end security 
  10. Minimize use of network connections, keep in mind that we also have push notifications 

PHP + WS
  1. Always think above $_POST, $_GET, $_REQUEST, $_FILE they are just to help you 
  2. Use and read headers generously
  3. php://input thats what you need 
  4. Don't forget your buddy "MIME types"
  5. Be prepared for Trojan and Injunction
  6. PHP is more related to network, explore its low level possibilities
  7. Take authorization and content distribution seriously

JS + WS
  1. Don't misuse client network and resources :|
  2. Just enjoy with JSON, sometime XML and leave it all for server side :)

Hide blog post from listing based on tags

CSS Part
<b:if cond='data:blog.pageName != &quot;Doodling&quot;'>
&lt;style&gt;
.just-hide-post{
display:none;
}
&lt;/style&gt;
</b:if>
   <!- JUST ABOVE YOUR HEADER CLOSURE TAG -->

iOS - Memory Management

Must follow:
  1. For every alloc, retain, copy you should have a release as soon as you are going to leave it
  2. Avoid using autoreleased objects, You can use autorelease objects but keep in mind that they will not be released until their pool is released
  3. Always respond to memory warnings and take them seriously 
  4. Stick to Lazy Loading, means defer initialization of an object until the point at which it is necessity.
  5. Don't release the objects that we don't own.
  6. Reuse your objects instead of declaring new ones, in possible scenarios.
  7. If you are not using same resource repeatedly then avoid methods like [UIImage imageNamed:@""] because these method will increase cache size, a better alternate is [UIImage imageWithContentsOfFile:@""]
  8. Build custom UITableCell, UICollectionViewCell etc; and reuse them properly
  9. Override setters properly
  10. Use initWithCapacity when size is known to you
  11. Use delegates carefully, remember to set delegate properties to nil before releasing its owner; otherwise, the object might think that its delegate is still there, and will send a message to an invalid pointer.
  12. Use LLVM/Clang Static Analyser tool. It will catch errors regarding the Objective-C naming conventions and hidden memory leaks when using foundation frameworks
Good to have:
  1. Enable Guard Malloc
  2. Enable NSAutoreleaseFreedObjectCheckEnabled
  3. Enable NSZombieEnabled
  4. Enable NSDebugEnabled




गुनाहगारों में आ पहुँचा खतावारों में आ पहुँचा

दयारे ज़ुहुत छोड़ा और मह्ख्वारो में आ पहुंचा
गुनाह ऎ जीस्त की खातिर गुनाहगारों में आ पहुंचा
मेरे दीरा ना हमदम खूब थे पर ये हकीकत है
सबाबित से गुज़र कर आज सैयारों में आ पहुंचा
गुलिस्तानो में रहता था खिज़ा के ज़ोर सहता था
बयाबानो में आ पहुंचा ज़ुनुज़रों में आ पहुंचा
सबिस्तानो के ख़वाब आवर नाज़िर कल की बातें थी
शहर के ज़फिज़ा में बेदार नज़ारों में आ पहुँचा
जो तालिब हैं सुकून ऐ जिंदगी उनको मुबारिक हो
हलाके जूस्तजू था मै की आवारों में आ पहुंचा
नज़र को खीरा कर सकती थी सीमोज़र की ताबानी
नज़र पलती है जिनमे ऐसे नज़रों में आ पहुँचा
मै बेगाना था यज्दा के परिस्तारों की महफ़िल में
ग़नीमत है की इन्सां के परिस्तारों में आ पहुँचा
ऊरूसे ज़िन्दगी की नाज़ परदारी का सौदा था
उरूसे ज़िन्दगी के नाज़ा पर्दारों में आ पहुँचा
अगर यह जिंदगी से प्यार भी एक ज़ुर्म है फ़िर तो
गुनाहगारों में आ पहुँचा खतावारों में आ पहुँचा
भटकता फ़िर रहा था दरबदर और कूबकू  ताबां
यह यारों का तसरुफ़ है की यारों में आ पहुँचा
दयारे ज़ुहुत छोड़ा और मह्ख्वारो में आ पहुंचा
गुनाह ऎ जीस्त की खातिर गुनाहगारों में आ पहुंचा

Error in Personal frameworks after installing new xcode


I have installed the new xcode version with my last xcode version which made me crazy because my project with some personal frameworks are stopped working :(

When I have checked the Framework code it is giving some strange error; "target specifies product type 'com.apple.product-type.framework.static', but there's no such product type for the 'iphoneos' platform"

After a long long gooooogling in the dark side which did't help me so much. I have found a simple solution, ie;

1) Quit both of XCode versions
2) Switch the active XCode version to the last one (in my case it is; sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer)
3) Reinstall "iOS Real Static Framework"
4) Clean and Build


Do get in touch with me in case you wish to discuss this further. Happy Coding ;)

Blackberry 10 (qnx) PhoneGap Plugins

We have two ways to create plugins for our BlackBerry PhoneGap apps ie; PG-BB Native Java and BB WebWorks

iOS App development with Windows and C

For folks who have Windows and wants to develop an iOS application or if you have written lots of code in C/C++ and just needed a standard API to display images, get touch events, mix sounds, perform file i/o and get access to the iPhone accelerometer data. You just need DragonFireSDK - very cool and inexpensive way to program and test an iPhone app.

SDK URL: http://www.dragonfiresdk.com

Docs URL: http://www.dragonfiresdk.net/help/DragonFireSDKHelp.html

Simple JS minification tool


ONLINE TOOL URL
http://closure-compiler.appspot.com/home



SAMPLE CODE
// ==ClosureCompiler==
// @compilation_level SIMPLE_OPTIMIZATIONS
// @output_file_name default.js

// ==/ClosureCompiler==

// ADD YOUR CODE HERE
function hello(name) {
alert('Hello, ' + name);
}
hello('New user');



TO INCLUDE EXTERNAL FILE
add following code with the full path to the files

// @code_url https://dl.dropbox.com/u/37581115/.js
// @code_url https://dl.dropbox.com/u/37581115/.js


Convert UIImage to Base64 and vice versa

Code used to convert an image to base64 or an UIImage to base64 NSString


Thats why i do lotz of spelling mistakes without hesitation

I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn’t mttaer in waht oredr the ltteers in a srod are, the olny iprmoatnt tihng is taht the frist and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can still raed it wouthit a porbelm.

Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Amzanig huh? Yaeh and I awlyas tghuhot slpeling was ipmorantt!

My PhoneGap app not working on ICS

I am working on an phonegap android app since last few months, after the launch of ICS i am shocked that phonegap functions are not supported on it. After some logs and alerts i have found that the code i am using to switch phonegap.js for iOS and Android is incorrect we need to replace it with simple call.

Hacking android app (Basic)

Search and download the apk file, you can use following links to search your apk if you don't have one

http://www.androiddownloadz.com/
http://www.freeandroidware.com/
http://www.freewarelovers.com/android

convert extension of the file from .apk to .zip and extract this zip, now you get the resources and other files, to get the classes decompile the file classes.dex to jar with an app from this link http://code.google.com/p/dex2jar/downloads/list

Step 1 extract the contents of dex2jar.*.*.zip file
Step 2 copy your .dex file to the extracted directory
Step 3 execute dex2jar.bat <.dex filename> on windows, or ./dex2jar.sh <.dex filename> on linux

then you can use jd-gui, the source code is quite readable as dex2jar makes some optimizations.

Frequently used Android Intents

Useful and commonly used Android Intents for frequently used tasks like managing apps, making call, sending SMS, eMail etc

Inspirational Message By Dr.Kalam

Why is the media here so negative?
Why are we in India so embarrassed to recognize our own strengths, our achievements? We are such a great nation. We have so many amazing
success stories but we refuse to acknowledge them.

क्यों मुझे गाँधी पसंद नहीं है?

अमृतसर के जलियाँवाला बाग़ गोली काण्ड (1919) से समस्त देशवासी आक्रोश में थे तथा चाहते थे कि इस नरसंहार के खलनायक जनरल डायर पर अभियोग चलाया जाए। गान्धी ने भारतवासियों के इस आग्रह को समर्थन देने से मना कर दिया।

गब्बर सिंह का चरित्र चित्रण

1.सादा जीवन, उच्च विचार: उसके जीने का ढंग बड़ा सरल था.

JS keyboard shortcuts library

Keymaster (keymaster.js) is a simple micro-library for defining and dispatching keyboard shortcuts with no dependencies on any other framework. Usage is so simple just include keymaster.min.js in your web app, by loading it as usual and write your shortcuts with modifiers like ⇧, shift, option, ⌥, alt, ctrl, control, command, and ⌘., for example;

National anthem truth


I have always wondered who is the " adhinayak"and"bharat bhagya vidhata",whose praise we are singing.. I thought might be Motherland India ! Our current National Anthem "Jana Gana Mana"is sung throughout the country.

Create/Deploy Android project by comand line

Creating and deploying a new Android project by Mac terminal is an exciting experience for me, for this all what i needed are Ant, Mac Terminal and Android SDK only :)

Installing or Upgrading Ant in Mac OSX

First of all Ant already come with Mac OSX, but if you really need to install it or want to upgrade it, though, the best way would be to install it through MacPorts (using sudo port install apache-ant). To install it manually you can follow these simple steps:

Installing and Configuring MacPorts

MacPorts are better way to install and updating various utilities in your mac, it is a command line tool.

Sencha Touch

Sencha Touch is a full mobile JS library, along with widgets, animations and all sort of utilities for mobile html5 development.

NCC theme song

Hum Sab Bharatiya Hain, Hum Sab Bharatiya Hain

Installing Ant plugin in Aptana Studio

Because Aptana is build for Web development it don't have Ant in its bundle (as it comes with Eclipse). We need to install JDT with some simple steps to run Ant in Aptana

Prepopulate SQLite DataBase in PhoneGap Application

This is an old post, please refer:
https://github.com/brodysoft/Cordova-SQLitePlugin - a Cordova/PhoneGap plugin to open and use sqlite databases on Android/iOS/WP(8) with HTML5 Web SQL API

It is really hard to wait for too much time when a phonegap application runs for first time and create all its database stuff, which gives a really bad impression to the user who just downloaded the app for its iPhone or Android device. I have a little approach to save the long time taken for database creation at very first run of the app, that is; we should copy a Pre-Populated Database file to the native location of device.

Sprite3D or 3D HTML5

I think we can say 3D-HTML ;) because Sprite3D wraps HTML elements with the necessary behaviors to easily control their 3D-position using a simple JavaScript syntax. It gives AS3-style properties and derivative support, Lots of accessory methods with a basic support for sprite sheets. Sadly Sprite3D is only limited to chrome browser yet.

Official URI: http://minimal.be/lab/Sprite3D/

FlyJSONP

FlyJSONP is a small JavaScript library, 2.38KB (1.13KB gzipped), that allows you to do cross-domain GET and POST requests with remote services that support JSONP, and get a JSON response.

Official URI : http://alotaiba.github.com/FlyJSONP/ 
Demo : http://alotaiba.github.com/FlyJSONP/#!/demo

Zen Coding to boost your HTML and CSS

Zen coding is an IDE plugin to boost your HTML/CSS typing speed, all what you need to know is little Zen coding syntax and DOM XPath knowledge. It supports a wide variety of code editors, including Espresso, Vim, Netbeans, TextMate, and Komodo Edit. It combine the power and specificity of CSS selectors with HTML mark-up, and you get Zen Coding. Certainly, I wasn’t the only one whose jaw dropped the first time when i saw that with a single shortcut in my Dreamweaver, for div#wrap>div#content>amp>ul#nav>li*3 it populated

{LESS} for CSS

LESS is an amazing little tool which helps to minify your CSS by using some JS stuff, it extends CSS with the addition of variables, mixins, operations and nested rules, this means you can write code very quickly.

Sketch Me Pro Success

WOW! I am too happy today with the Growth of Sketch Me Pro.
My application Sketch Me Pro getting a huge success in Android App market, with more then 10k downloads in time period of less then 15 days. Today it is in top of hot photography apps category of appbrain.com,

Social network comparison

How to chose a Social networking site for our favorite services like Video Chat, Status Update, etc. lets have a look to a interesting comparison info-graphic.

Unique features of Android OS

There are other smartphone OS available out there, but Android have some individual features that other OS do not have like: 

knockout.js

knockout.js: A pure lightweight JavaScript library that simplifies the creation of dynamic user interfaces by MVVM (Model-View-View Model) architecture with cross browsers support. (something similar like Mustache.js)

Related Posts Widget in Blogspot

NOTE: Back up your existing Template before making any changes!

Open you blog's template in expanded mode for editing; Just after </head> tag add <script src='http://dl.dropbox.com/u/9050117/blogspot_related_post.js' type='text/javascript'/> and just after <data:post.body/> and following code snippet:

JS Fiddle

Suppose you want to test a JS snippet and test it, then all you have to do are; create a HTML page then write stuff on it then run it on a browser such a boring and long phenomena and these type of junk page we lost them almost in our huge file base and after a longtime when you really need this code or you want to share with you friend then you have to do a huge search to find that file..... get rid from all this with JSFiddle.

BDD vs TDD

If you’re not familiar with these acronyms, they stand for Behaviour-Driven Development and Test-Driven Development, BDD is little more complex as compare to TDD here are some of the basic differences:

Mustache.js

 Mustache.js is KISS(keep it simple stupid) Logic-less template engine quite useful when writing web applications.

WebSocket in HTML5

HTML5 provides a new thing called a WebSocket. Now data can flow between the browser and server without having to send HTTP headers until the connection is broken down again. Welcome to the world of PUSH technology!

What is Websocket?
WebSocket is bi-directional (full-duplex) communication channel over a single TCP (Transmission Control Protocol) socket for client or server application... goes too much technical, ok then
WebSockets opens a connection to a server and the connection stays open until you decide to close it. From there, you can start sending messages from the browser to the server and you can define a callback function for when the server send data back. Basically we got rid of each time new request for server.

Periodic Table of Typefaces

Periodic Table of Typefaces : Popular, Influential & Notorious (wallpaper)
An interesting collection of fonts and guess what you also can order to past it on your workshops wall ;)

Get a Periodic Table of Typefaces for yourself!