Wednesday, December 31, 2014

Different Apple Processors

Below diagram gives an overall idea of different processors Apple has released till date

Before A4 series, there did not exist a naming convention like AX, the Apple iPhone 3Gs, iPod Nano, earlier versions of iPod Touch devices had chips APL0098, APL0278, APL0298, APL2298 etc. 
A4 was introduced in iPad 1st gen, iPhone 4, iPod Touch  (4th gen) Apple TV, iPad 2, iPhone 4S
A5 was introduced in Apple TV 3rd Gen, iPad 2, iPod Touch, iPad Mini , Apple TV 3
A5X was introduced in iPad 3 devices
A6 was introduced in iPhone 5 and iPhone 5C
A6X was introduced in iPad 4th Gen 
A7 was introdueced in iPhone 5S, iPad mini 2, iPad mini3, iPAd Air
A8 was introduced in iPhone 6, iPhone 6 Plus
A8X was introduced in iPad Air 2
S1 is getting introduced in Apple Watch 

A7 processor is a 64 bit processor. It is faster than A5 in terms of CPU performance and 8 times faster than A5 in terms of GPU performance. 
A7 also got image signal processor, Secure Enclave for storing and processing the Tocuh fingerprint data, in addition, it has Motion sensing, Gyroscope. 
M7 Chip is a co-processor, which can help chips such as A7 from overheating because it has to do lot of processing since it is 64 bit architecture. M7 especially is a motion sensor processor. 

References

iOS Header Docs and Snippets

Creating code snippet for code documentation is an easy way to manage the template for code documentation. E.g. below will generate a method template 

/*
*  @brief <#description>
*  @param <#param description>
*  @param <#param description>
*   
*  @return <#return description>
*/

By selecting this drag and drop into the snippet area and give the proper name and description. In the shortcut space, write something like doccomment. 
On the method signature to the extrement left, i..e left to the - symbol, start typing doccomment. Xcode will fill in the template snippet. Each items those are put under the 
<#> format will be navigable by using tab. This is so cool. 

References:

Amazon Echo

Amazone echo is designed around a user’s voice. It is always on, just ask for information, music, news, weather and more. Echo begins
working as soon as it detects the wake word. A user can pick Alexa or Amazone as the wake word. Echo is an expertly tuned speaker that can 
fill any room with immersive sound. 



This device uses FAR field voice recognition method. Tucked under Echo’s light ring is an array of serven microphones. These sensors use beam forming technology to hear user  from any direction. 
With enhanced noise cancellation, echo can hear user asking for question while its playing music. Echo uses on device keyword spotting to detect the wake word. When it detects the keyword, it lights up the and streams audio to the cloud where it uses the power of amazon web services to recognise and respond to the request. 

References

Bluetooth support in iOS

When configuring the AVAudioSession, application can specify whether it allows Bluetooth devices like below 

success = [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];
if (!success) {
    NSLog(@"setCategoryError");
}

The list of Bluetooth profiles supported by the application is given below in the table by Apple

The major profiles are below 

Handsfree profile (HFP 1.6) 
Phonebook Access profile (PBAP) 
Advanced Audio Distribution Profile (A2DP)
Audio Video Remote Control Profile (AVRCP 1.4)
Personal Area Network Profile (PAN)
Human Interface Device Profile (HID)
Message  Access Profile (MAP)

There is a bluetoothe Apple developer portal which gives Application accelerator. But this is more about testing and verifying the profile implementations. 


References: 
http://stackoverflow.com/questions/20896528/how-to-find-bluetooth-audio-devices-in-ios

Charles Proxy - SSL and Non SSL traffic interception

Charles Proxy - SSL and Non SSL traffic interception

Since as part of a project had to do some network monitoring to know whether the library is making a network connection and it fails or even without doing any of the network request it fails. 
The first part of this was to download the Charles proxy for MAC Os. this can be downloaded from the location http://www.charlesproxy.com/documentation/installation/ http://www.charlesproxy.com/download/

In order to decrypt the encrypted traffic, the device needs to install the certificate given by the Charles. This certificate acts as an intermediate certificate between client and server. When the server sends encrypted traffic it is able to decrypt because the certificate info that is passed to the server is the charles one. 

In latest versions of Charles, we also have to add the site which needs to be SSL decrypted in to the filter under proxy settings under Locations tab. Like shown in the image below.



References: 

Objective C - Few tips for good programming


- Declare Public Properties for exposed data 
Use @property keyword that expose an objects value to outside. By default property is public and readwrite, use readonly if required 
- Use Meaningful name for the properties. For e.g. requestInProgress BOOL flag may have accessor method as @property (readonly,getter=isRequestInProgress) BOOL requestInProgress;
- By Default property is having strong reference. So, declare them to be weak for it be weakly referred. 
- For local variables, use __weak or __strong to make the variable weak or strong 
- When a weak instance variable is assigned to a local variable, the local variable since by default is strong, it will be safe to do the operation until the scope of the local variable finished
For e.g. 
- (void) someMethod 
{
NSObject *cachedObject = self.weakProperty;
[cachedObject doSomething];
}

- Use unsafe_unretained for those classes which doesn’t support weak yet. There are few classes such as NSFont, NSTextView 
- If we have a readonly property, in the header file and want to assign values to it inside the .m file, then either use _propertyName to access it or in the .m file, override the property as readwrite like below 
in .h file 

/**
 * @brief TRUE if the notification detail is already cached. FALSE otherwise.
 */
@property (nonatomic,readonly, getter=isNotificationDetailsCached) BOOL notificationDetailsCached;

In the .m file, either of the below 
@property (nonatomic) BOOL notificationDetailsCached;
self.notificationDetailsCached = TRUE;


references:

Tuesday, December 30, 2014

What is iOS 64 bit architecture?


Starting with iOS 7 and the A7 processor, we can build the apps that take advantage of 64 bit processor. An app that supports 64bit processing almost always gains improved performance when compared with a 32 bit app running on the same device. 

The Apple A7 processor supports two distinctive instruction sets. The first is the 32 bit ARM instruction set supported by Apple’s previous processors. The second is the brand new 64 bit ARM architecture. The 64 bit architecture includes support for vastly larger address space, but that is not only the major improvement it provides. The 64 bit architecture provides new streamlined instruction set that supports twice as many as integer and floating point registers. Apple’s LLVM compiler has been optimised to take full advantage of this architecture. As a result, 64bit apps can work with more data at once for improved performance. Apps that extensively use 64 bit integer math or custom NEON operations see even larger performance gains. So, even though 32 bit apps run faster already on A7 processor, converting the apps to 64 bit almost always provides a better performance. 

When a 64 bit app is running in iOS, pointers are 64 bits, Some integer types, once 32 bit are also now 64 bits. Many data types in the system frameworks, especially UIKit and foundation have also changed. These changes mean that a 64 bit app uses more memory than a 32 bit app. If not managed carefully, the increased memory consumption can be detrimental to the app’s performance. 

When iOS is executing on a 64 bit device, it loads both 32 and 64 bit versions of the system frameworks. When all apps running on this device is converted to use the 64 bit architecture, iOS never loads the 32 bit version of the libraries. As a result system never uses the 32 bit version and apps loads faster.  


References:

Monday, December 29, 2014

Android Connectivity State Change notifications

The basic intention was to create an app that sends a message to someone automatically when get home or reach office. 

Initially two broadcast relievers were included 
android.net.conn.CONNECTIVITY_CHANGE
and 
android.net.conn.WIFI_STATE_CHANGE

This worked well, but there was a problem that whenever user manually change the wifi switch, the WIFI_STATE_CHANGE get reported immediately. This is a big problem when wifi is getting connected. If we try to read the SSID after getting the WIFI_STAGE_CHANGE callback, it doesn’t give the SSID. To reliably know which SSID the device s connected, Just need to implement the CONNECTIVITY_CHANGE broadcast. The code was something like below 

also in order to use the above broadcasts, below permissions had to be specified in the manifest file 

    
   
   

The boot completed event was just to identify if switched on in a different region than the last reported one. 

public void notifyNetworkChange(Context context, boolean gain)
    {
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                new Intent(context, MainActivity.class), 0);

        String ssidStr = "none";
        String bssid = null;
        Log.v("RR:","value for gain is:"+gain);
        if(gain)
        {
            WifiManager wifiManager = (WifiManager)context.getSystemService (Context.WIFI_SERVICE);
            if(wifiManager != null)
            {
                Log.v("RR:","wifiManager not null");
                WifiInfo info = wifiManager.getConnectionInfo ();
                if(info != null) {
                    Log.v("RR:","info not null");
                    ssidStr = info.getSSID();
                    bssid = info.getBSSID();
                }
            }
        }
        if(ssidStr != null)
        {
            Log.v("RR:","ssid not null");
        }
        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(context)
                        .setSmallIcon(R.drawable.ic_launcher)
                        .setContentTitle(gain? "WiFi Connected" : "WiFi Lost")
                        .setContentText(bssid == null ? "Disconnected from WiFi" :"Connected to "+ ssidStr +" Wifi.");
        mBuilder.setContentIntent(contentIntent);
        mBuilder.setDefaults(Notification.DEFAULT_SOUND);
        mBuilder.setAutoCancel(true);
        NotificationManager mNotificationManager =
                (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(1, mBuilder.build());

    }


Sunday, December 28, 2014

Android Broadcast Receiver - Part 1


A broadcast receiver allows application to register for System or application events. All registered receivers are notified by the Android system when the event happens. 
For e.g application can register for ACTION_BOOT_COMPLETED system event which is fired once Android system has completed boot process. 

Receivers can be implemented by 

1. Specifying a receiver in the AndroidManifest.xml file. This is called static registration 
2. Also, apps can do dynamic registration by calling Context.registerReceiver() method. 

The implementation class should extend the BroadcastReceiver class. When the event for which the receiver class has registered happens, the Android system calls the onReceive() is called by the Android System. 
After onReceive is called by the Android system, the Android system likely to recycle the receiver instance. 

Before API level 11, Application was not allowed to perform any asynchronous operation in the onRecieve method because the System likely to destroy the receiver instance. 
Since API 11, receiver implementation can call the goAsync method. This method returns the PendingResult type. Android system considers the receiver to be alive until the PendingResult.finish is called. 

As of Android 3.1, the android system excludes all receiver from receiving the broadcast intents by default if the corresponding application has never been started by the user or if the user explicitly stopped the application via 
Android menu (in Manage -> Application.

This is an additional safety as the user can be sure that only the applications he started will be able receive broadcast intents. However, in previous device boot session if the app was not killed by the user, then Android system 
gives the boot event to the receiver 

System Broadcasts
Several system events are defined as static fields in Intent class. Other android system classes also define events. e.g. the TelephonyManager defines events for the change of phone state. The following are the list of important events

Intent.ACTION_BOOT_COMPLETED => Boot completed. Requires android.permission.RECEIVE_BOOT_COMPLETED 
Intent.ACTION_POWER_CONNECTED => Power connected to the device 
Intent.ACTION_POWER_DISCONNECTED => Power disconnected from device. 
Intent.ACTION_BATTERY_LOW => Triggered on battery low. Typically can be used to reduce battery intense operations. 
Intent.ACTION_BATTERY_OKAY => When battery is at good level. 


references:
http://www.vogella.com/tutorials/AndroidBroadcastReceiver/article.html#broadcastreceiver_definition

Friday, December 26, 2014

Apple’s TestFlight Beta Testing

With TestFlight beta testing, one can distribute pre-release builds of the app to testers to collect feedback and prepare for app release in the store. 
This is completely optional and we can submit for review without using it. 



Below are few simple steps in creating and using Test Flight application  

The build should contain Beta Entitlement it looks like.

Step 1: Locate Pre-Release tab 

Step 2: Enter details about the build 
This section tells what to test and what is the description of the app. We can also give the feedback email and marketing policy URL. 

Step 3: Enable Internal Testers  
For this, navigate to Users & Roles 
Select any user and enable him as Internal Tester. 

Step 4: Switch On Testing 
After saving the internal tester in the Users & Roles screen, go back to the pre-release screen and turn on testing

Step 5: Invite Testers 
For this, go to Internal Testers tab and select the testes to be enabled and press on Invite button. 
These users will receive email inviting them to the account. Once the testers accept, the status will be updated in the iTunes accordingly against each of these testers as Accepted
These testers once they Install the build, the status in iTunes will indicate as Installed. 


Few additional notes:

- Every documents are referring the build upload test using the Xcode. However, based on few reference discussions, it appears that we dont really need to use Xcode, instead can just upload ipa and go to the pre-release tab and do the items mentioned above. 

- 25 internal members can do the test without undergoing the beta app review process. But if we need to give to external testers (max 1000 external testers are allowed), then we need to go through Apple’s Beta review process. 

- Since the build to be made with App store distribution profile, assuming we can very well do the app store upgrade tests. 


Referecens: 

Apple Pay - Doing the Programming

The coding is fairly simple and it is like below


#import

We have to include the PassKit Framework and do the import below

Add a button and on the action do the below

-(IBAction) payButtonPressed:(id)sender
{
    if([PKPaymentAuthorizationViewController canMakePayments])
    {
        PKPaymentRequest *request = [[PKPaymentRequest alloc] init];
        request.countryCode = @"US";
        request.currencyCode = @"USD";
        request.supportedNetworks = @[PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa];
        request.merchantCapabilities = PKMerchantCapabilityEMV;
        request.merchantIdentifier = @"merchant.com.mportal.applepaytest";
        PKPaymentSummaryItem *amount = [PKPaymentSummaryItem summaryItemWithLabel:@"amount" amount:[NSDecimalNumber decimalNumberWithString:@"0.99"]];
        PKPaymentSummaryItem *tax = [PKPaymentSummaryItem summaryItemWithLabel:@"tax" amount:[NSDecimalNumber decimalNumberWithString:@"1.00"]];
        PKPaymentSummaryItem *total = [PKPaymentSummaryItem summaryItemWithLabel:@"Grand Total" amount:[NSDecimalNumber decimalNumberWithString:@"1.99"]];
        request.paymentSummaryItems = @[amount, tax, total];
        
        self.paymentPane = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
        if(self.paymentPane != nil)
        {
            paymentPane.delegate = self;
            [self presentViewController:paymentPane animated:TRUE completion:nil];
        }
        else
        {
            [self showMessage:@"Error while creating payment pane"];
        }
    }
    else
    {
        [self showMessage:@"Apple Pay Not supported"];
    }
    

}


Below are the call backs for the 

// Sent to the delegate after the user has acted on the payment request.  The application
// should inspect the payment to determine whether the payment request was authorized.
//
// If the application requested a shipping address then the full addresses is now part of the payment.
//
// The delegate must call completion with an appropriate authorization status, as may be determined
// by submitting the payment credential to a processing gateway for payment authorization.
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                       didAuthorizePayment:(PKPayment *)payment
                                completion:(void (^)(PKPaymentAuthorizationStatus status))completion
{
    [self showMessage:@"didAuthorizePayment called back"];
}

// Sent to the delegate when payment authorization is finished.  This may occur when
// the user cancels the request, or after the PKPaymentAuthorizationStatus parameter of the
// paymentAuthorizationViewController:didAuthorizePayment:completion: has been shown to the user.
//
// The delegate is responsible for dismissing the view controller in this method.
- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
{
    [self showMessage:@"paymentAuthorizationViewControllerDidFinish called back"];
}

/ Sent when the user has selected a new shipping method.  The delegate should determine
// shipping costs based on the shipping method and either the shipping address supplied in the original
// PKPaymentRequest or the address fragment provided by the last call to paymentAuthorizationViewController:
// didSelectShippingAddress:completion:.
//
// The delegate must invoke the completion block with an updated array of PKPaymentSummaryItem objects.
//
// The delegate will receive no further callbacks except paymentAuthorizationViewControllerDidFinish:
// until it has invoked the completion block.
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                   didSelectShippingMethod:(PKShippingMethod *)shippingMethod
                                completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray *summaryItems))completion
{
    [self showMessage:@"paymentAuthorizationViewController called back"];
}

// Sent when the user has selected a new shipping address.  The delegate should inspect the
// address and must invoke the completion block with an updated array of PKPaymentSummaryItem objects.
//
// The delegate will receive no further callbacks except paymentAuthorizationViewControllerDidFinish:
// until it has invoked the completion block.
- (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller
                  didSelectShippingAddress:(ABRecordRef)address
                                completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray *shippingMethods, NSArray *summaryItems))completion
{
    [self showMessage:@"didSelectShippingAddress called back"];
}

References:

Apple Pay - Setup Process Involved.

Did a hands on setting up the App ID for enabling the Apple Pay. Below are few notes on this

- App Vendor need to enable Apple Pay in the bundle ID of the App.
- In order to enable Apple Pay, need to create a Merchant ID in the iTunes account of the App in which it belongs
- Merchant ID is created by a series of steps such as creating a bundle ID, CSR and associating CSR with the created Merchant ID etc
- Once this is done, Application need to enable the Apple Pay in App Capabilities, which will trigger Xcode to validate if Apple Pay is enabled for this bundle ID by checking with the Apple Developer account. 
- Once this is done, Application can include PassKit framework and few code snippets, the Apple Pay feature can be enabled. 
- Apps can check fi the device is able to support Apple Pay and only if yes, can enable the Apple Pay button in the app ui. 
- App can pass the info ( in form of standard and custom fields) to the backend server, the server should be able to handle this token  and extract the info. For the decryption service, the server code can employ third party SDKs and it is normal as per the documentation and samples available. 

Simple code snippets to Demonstrate this concept is getting added in next article.

- When tried with iPhone 6 Plus, was not fully able to test this out because the card validation was failing when adding the card in Passbook app. 

Few other notes:

- Apple pay is not possible within the enterprise app account. (Merchant ID section is not listed for enterprise accounts under Identifiers in Developer account), so we have created the sample using the developer account. 
- Felt like the concept is much similar to Apple Push notification, with a difference that, Apple Push notifications flow from server by encrypting the data with the certificate on the client and the certificate on the server. With Apple pay, the data is encrypted from client (in form of token) and decrypted at the server. 


References:

Apple Pay - A bird's eye view

Apple Pay uses contact less payment technology with the NFC along with the unique security features built into the device. With Apple Pay, user can make payment with iPhone, Apple Watch, iPad in a simple, secure and private way. 

iPhone 6 experience: 
With Touch ID, the payment experience is in natural motion, There is no need to wake the app or turn on the display. The NFC antenna in the iPhone knows that the device is near payment machine and brings up the app. User can just tap on the finger print home button The payment will be done and a subtle beep or vibration will let user know that the payment was done successfully. 



Apple Watch Experience
In Apple watch, double clicking the button next to the digital watch crown and hold it near the card reader facing the face of the watch on the reader. A gentle pulse and beep confirm the payment was sent. 



Pay within Apps
On iPhone 6, iPad Air 2 and iPad mini3, one can also use Apple pay to pay with single touch to pay within apps. Checking out is as easy as Selecting Apple pay and placing the finger on Touch ID.

How do a user setup the Apple pay 

Basically passport now can store the credit card details too. To get started, user can add credit or debit card from iTunes account to passbook by simply entering card security code. To add a card on iPhone 6, iPad Air 2 or iPad mini 3, go into settings, Open Passbook  & Apple Pay and select Add Credit or Debit Card. On iPhone, just open passbook, then swipe down and tap the plus sign. From there use iSight camera to enter card information or type in manually. 


More Secure Payments 
Everytime when we handover the credit / debit card for payment, the Identity is visible. With Apple Pay, instead of using actual credit card, when a card is added a unique Device Account Number is generated, encrypted and securely stored in a Secure Element, a dddicted chip in iPhone 6, iPad and Apple watch. These numbers are never stored on Apple servers. When some one makes a purchase, this DAN along with dynamic purchase characteristics and also a transaction specific dynamic security code is used to process the payment. So, the actual card is not involved in the transaction with Apple servers. 

Below are the major banks those support Apple Pay: 
American Express, BOA, barclycard, BB&T, CapitaleOne, CHASE, Citi, Commerce Bank, M&T bank, Navy Federal, PNC, REGIONS, SunTrust, TDbank, USAA, USBank, Wells Fargo

References: 
https://www.apple.com/apple-pay/

Thursday, December 25, 2014

Android Getting connection state changes

The intention was to create an app which sends a message to my wife when i reach home or when reach office network. For this, below are the items done 


               
                   
                   
               
           

Now create the class the extends the broadcast receiver. 

public class NetworkChangeReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(final Context context, final Intent intent) {
        final ConnectivityManager connMgr = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);

        final android.net.NetworkInfo wifi = connMgr
                .getNetworkInfo(ConnectivityManager.TYPE_WIFI);

        final android.net.NetworkInfo mobile = connMgr
                .getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

        if (wifi.isAvailable() || mobile.isAvailable()) {
            // Do something
            Log.d("RR::Netowk Available ", "Flag No 1");
            Toast.makeText(context, "Network Available Do operations", Toast.LENGTH_LONG).show();
        }
        else
        {
            Toast.makeText(context, "Network Not available.", Toast.LENGTH_LONG).show();
        }
    }
}

However, the above did not really work out as expected. It was not getting the broadcast receiver call backs. Yet to investigate more on this. 

Finally, found the root cause,  the error was simple, that the receiver xml tag was not right under the application element in the AndroidManifest.xml file. Once i made this, it was able to properly get invoked on network state changes! 

Wednesday, December 24, 2014

Beacon Signal Characteristics

Happened to read about a good article that explains the beacons and ranging etc. Below given few understanding from it

We have to consider a beacon at the centre of a sphere and radio signals being the sphere, with this imagination below concepts are applicable. 

RSSI (Received Signal Strength Indicator)
This is a generic measure of power present in the received signal. The signal strength depends on first and foremost the TxPower. When the TxPower is set to maximum (+4) the RSSI ranges from -26 (few inches) to -100(40-50m distance) 

Signal Direction
Beacons emit signals in every direction at once, much like the sphere. 

Range
The signals range could be reduced down to few inches or increased to cover areas as wide as 230ft (70mts) Various forms of interference can negatively impact range, in addition wider ranges consume more power. 

Battery Strength and Signal Degradation
Normally battery levels should not have a direct impact on the signal strength unless the battery is critically low. 

Determining the position of a mobile device
It is possible to get the information about the distance between beacon and a mobile device. The term in known as “distance” and is measured in meters. 

Reported Distance between a Mobile Device and a single Beacon. 
When ranging a beacon, the measured distance between the beacon and the device can vary and can fluctuate heavily. This is because of the 2.4GHz radio wave spectrum is highly susceptible to external factors, like multi path propagation, diffraction, absorption and interference. 

Looks like estimate team has already done some tests around this and the values are like below 

Distance of 20cm : deviation is 5-6 cm
Distance of 1 m : deviation is 15cm 
Distance greater than 10 m: deviation is 2-3 meters 

The fluctuations will be more visible in Android platform and less in iOS because iOS already has noise reduction techniques implemented in to the CoreLocation framework. Android bluetooth stack on the other hand doesn’t have this yet. 

Zones: 
There are 3 static Zone surrounding each beacon. 

Immediate Zone (0-20cm) 
- When device is held up close to beacon 
- Accuracy confidence is high

Near Zone (20cm - 2m)
- Within a couple of meters to the beacon 
- Accuracy is fairly certain 

Far Zone (2-70m) 
 - More than a few meters away
- Accuracy is low or the signal strength is weak 

Zones are not adjustable, they are preset boundaries that fit within the confines of the radio signals reach. As an example, if the range is reduced to 10m, all three zones remain available, if the range is reduced to 1.5 m, only two zones available. 


references:

WiFi Router Recommended Settings

WPA2-Personal => Strongest using AES encryption, recommended for all users. This is best if the Wifi devices and the router is latest. Both can communicate with strongest level of encryption 
WPA/WPA2-Personal => This is a dual mode. IF we have some devices in the network of this router which doesn’t support WAP2-Personal, those devices still will be able to connect using WPA. The newer devices those support WPA2-Personal will still be able to use strongest encryption mode for connection
WPA-Personal => If the wifi router doesn’t allow the setting of WPA/WPA2-Personal, the next choice is WPA-Personal. Less secure, but better than options below. 
WEP-TSN =>  In general WEP mode is obsolete and less secure. However, WEP-TSN mode (Transitional Security Network) allows legacy WEP clients to join and also newer Wifi devices to connect with WPA2 or WPA-Personal. 
WEP-128 - This is less secure than WEP-TSN 

WEP-64 - Less secure than 128 WEP, in terms of key strength. 

reference: 

Tuesday, December 23, 2014

Code Documentation in Xcode Objective C - Part 1

HeaderDoc was added in Xcode 5.0 release and with iOS 7.0.
HeaderDoc is a nice command tool that a developer can use to automatically generate nice HTML documentation of the code as long as the code comments are in a particular structured way. 
In addition, Xcode also parses the HeaderDoc style comments behind the scenes to automatically present the documentation in quick look panels. 

There are three styles of comments that HeaderDoc scans for. 

Option 1: 
/// The documentation goes here

Option 2: 
/**
* The documentation goes here
*/

Option 3:
/*!
* The documentation goes here
*/

All three result in same if the documentation is done in Xcode. 

Below could be one approach we can follow in documenting 

1. Use /*! … */ for large code block comments 
2. Use /// for Single line comment for smaller code comments 

HeaderDoc tags

Once the headerdoc finds a comment in one of the above styles, it will search that comment for tags for more information. There are two types of tags, Top-Level tags and Second Level tags

Esmple of top level tag is @typedef. These define type of things we are commenting for e.g. Headers, classes, methods etc. 
Second level tags help to give more details about specific things we are commenting 

Few main tags in second level comments are @brief, @discussion, @abstract, @param, @return. This is not complete set of tags and the complete set can be found at the apple website given in the references

Documenting Properties

For documenting properties, it is just sufficient to have brief keyword, example like below

/*!
* @brief This is documentation of a property. 
*/

After documenting the properties, 

Documenting methods. 

Below documentation provides a good information to the user. @brief tells description of the method, @param indicates the parameter list, 

/*!
 * @brief Adds a notification to the notification list locally.
 * Once a notification is added, the notification properties will contain the 
 * key kMPNotificationSource property set to "local" indicating this is a 
 * locally generated notification.
 *
 *
 * @param properties : Properties of a notification to be added.
 * @return If the notification is added successfully the return value will be nil
 * If could not, the NSError object will be returned describing the error.
 */

In Xcode, the above appears like the below screenshot upon Option + Click 


In case if there is a warning to be added, @warning tag can be used.  After this change, the method will look like this below. 

/*!
 * @brief Adds a notification to the notification list locally.
 * Once a notification is added, the notification properties will contain the 
 * key kMPNotificationSource property set to "local" indicating this is a 
 * locally generated notification.
 *  
 * @warning the properties dictionary must not be nil.
 *
 * @param properties : Properties of a notification to be added.
 * @return If the notification is added successfully the return value will be nil
 * If could not, the NSError object will be returned describing the error.

 */



References: 

Sunday, December 21, 2014

iOS version support in various Apple devices

Only when i got the message "iOS 5.1.1 Your software is up to date" I realized that not all iOS devices support latest iOS versions. Below given table gives this info.


references:
http://www.everymac.com/systems/apple/ipad/ipad-faq/ipad-operating-system-info-update-cost-app-support.html

Wednesday, December 17, 2014

3rd Party Keyoard in iOS - App developer perspective

Few notes on Third party keyboards in iOS. 

- The main reason with the UI Alignment issue was because of the keyboard height was coming as zero for with the methods we use. 

Initially when the keyboard shown notification arrives at the application, below method is used to get the keyboard height 
[[[aNotification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&rectKeyboardFrame];

However, above gives height zero for  third party keyboards while it works well with the System keyboard. Since the view is moved up based on the height returned from this API, the ui looks distorted. To fix the issue, we can replace the API call to the below if in case the height comes as zero. 

[[[aNotification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&rectKeyboardFrame];

Also, as per the documentation, there are some privacy concerns when user employs the third party keyboard. 

An app developer can elect to reject the use of all custom keyboards in their app. For example, the developer of a banking app, or the developer of an app that must conform to the HIPAA privacy rule in the US, might do this. Such an app employs the application:shouldAllowExtensionPointIdentifier: method from theUIApplicationDelegate protocol (returning a value of NO), and thereby always uses the system keyboard.

This is mainly because these keyboards iOS 8.0 extension can potentially communicate the keystrokes to the server if these are run with full access (in keyboard settings).  

If the app has any payment related features, we can give kind of warning to the user and if user don’t want to enable third party keyboard, then application can altogether reject the third party keyboard for the app. In terms of using the above method, below are few observations on this.

- This method called to the app, whenever user activates the keyboard by tapping on the text fields. However, this method called back for even System keyboard with the same extension point identifier value which gives difficulty for an app to show a warning message if only user has 3rd party keyboard. Not sure this is a bug and will be fixed later in Apple releases, but we observe this in multiple iOS 8.x version as of now. 


- This method if returned NO, altogether disables the 3rd party keyboard for the app. This works well, however, this is not flexible enough to disable the third party keyboard only for  certain screens. For e.g. Not possible to disable third party keyboard for only for payment screens. 

References: 

Monday, December 8, 2014

Extensions Do they require a separate provisioning profile?

Yes, this is because extension is also considered as a separate app in the iOS runtime. There are two ways to do it. Extensions are separate targets from host app. They are actually having different bundle identifier suffixed with the bundle identifier of the containing app. 

1. Create a wildcard provisioning profile. 
2. create a separate bundle identifier and profile for it. 

The first one is not really recommended because some of the capabilities are enabled for the extension. For e.g. the AppGroups so that the host app and the extension can access the same container. 
Decided to choose the option #2, and for this, created a separate bundle identifier and created a provisioning profile which actually solved the problem of Xcode build step giving the error something like below. 

No matching provisioning profile Found. 

The provisioning profile specified in the build settings ("AppExtensionName") has an AppID of 'net.companyname.appName' which doesn't not match the bundle identifier net.companyname.AppName.extensionName.
Xcode can resolve this issue by downloading new provisioning profile. 

References: 

3rd Party Keyboard in iOS 8.0


Third party Keyboards are one of the most intriguing features of iOS 8.0. Google already had allowed creating custom keyboard for developers. The third party keyboards are now available in iOS, but how to use them is not so obvious. Some of these keyboards access internet and affects the privacy of the user. These keyboards work as Keyboard Extensions in iOS. Inorder to activate the third party keyboards, often we have to do the below 

Open Device Settings -> General -> Keyboard -> Add New Keyboard -> (Name of Keyboard) -> Allows (Full Access)

One thing noted is that such keyboards doesn't get activated in the password fields. While Apple OS itself restrict the apps from allowing the 3rd party keyboards to appear in the protected fields such as passwords, app should also be taking care of this to avoid such keyboards popping up in the fields such as credit card entry fields.  


References: 


Sunday, December 7, 2014

What is Google Express



Accidentally happened to see the Google Express Service that Google Offers. 

This service basically delivers the orders from local stores and popular retailers same day or overnight!. This is online shopping just wrapped with Google's loyalty and it basically revolves around Google Wallet. 
Google Express hosts a shopping website which lists products from multiple retailers and lets the user shop all items he need in one place, and add items into the cart, select a delivery window and checkout with Google Wallet. 
This order is processed in the store and delivered via courier in the window selected by the user. 

There needs to a Google Express membership and the delivery is free if the purchase is above $15. Also, new customers can try for 3 months for free. 


References: 
https://www.google.com/shopping/express/#HomePlace:s=0&c=60&mall=Manhattan

Storyboard - Part II - Prototype Cells


Prototype cells allows one to design custom layout for the table view cells from the storyboard editor itself.  The table view controller comes by default with a blank prototype cell. From the attribute inspector, one can select the Style to Subtitle and this includes two labels in the cell. However, running the app doesn't yet show this cell as the data is not yet available for displaying the cells. 

Since the sample decides to use Custom cell type, below few additional items are to be done. The style attribute needs to be set to None. The row height set to 55. 

The main work was in AppDelegate. The main idea was to link the data from AppDelegate to the table view controller. The table view controller was inside a navigation container controller and which is inside the Tab bar container controller. 
Below is the code to access the table view controller from app delegate in this code. 

Tabbar controller is the root view controller in the application. 

UITabBarController *tabcontroller = (UITabBarController) self.window.rootViewController; 
UINavigationController *navController  = [tabController viewCotnrollers][0]; // this fetches the navigation controller at the tab 0. This assumes that the navigation controller is at tab 0. 
PlayersViewController *playerViewController = [navController viewcontrollers][0];
playerViewController.players = _players; 

Inside the PlayersViewCotroller, the cell for row index path needs a bit of modification to give the cell identifier as the identifier we gave in the Prototype Cell.  

static NSString *CellIdentifier = @"PlayerCell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:CellIdentifier];
    }
    
    // Configure the cell...
    Player *player = (self.players)[indexPath.row];
    cell.textLabel.text = player.name;
    cell.detailTextLabel.text = player.game;

Thats it! . Its all done. 

References: 

Saturday, December 6, 2014

Storyboard Tutorial - Part 1


The main advantages of using the story board are the below ones

- With the storyboard, we can have a better conceptual overview of all the screens in the app and its connections between them. Its easier to keep track because entire design is in a single file rather than spread out in different files
- The storyboard describes transition between various screens. The transitions are so called “Segues” and this can be created by ctrl dragging from one view controller to the next. 
- Storyboards makes working with the tableviews lot easier with the new prototype cells and static cells features. We can design the table views almost completely in the storyboard editor, something like that cuts down the amount of code we write

Decided to follow the same exact steps mentioned in the tutorial at this link http://www.raywenderlich.com/50308/storyboards-tutorial-in-ios-7-part-1 

A story board contains multiple ViewControllers. Each view controller is called scene. On an iPhone only one scenes will be visible at a time. But in iPad, multiple scenes could be visible at a time. For e.g. master - details panes in a split-view, or content of a popover. 
The tutorial said to disable the Autolayout. With Xcode 6.1, we also have use Size Classes check box. this also needs to be commented. When unchecking these both will give the iPhone only view size. 

The Example then create tabs for this drag the TabBarViewController from the object list and this will add two view controllers as the tab bar controller comes with two view controllers by default, one for each tab. UITablViewCotnroller is so called container view controller since it contains other view controllers. Other examples of container view controllers are Navigation controller and Split View controller. 

The tutorial instructs to keep one label each in these two view controllers and give the labels to them as First tab and second tab. In the property inspector of the tab bar view controller, 

To experiment myself, just dragged the Tab View Controller to the storyboard and then to individual view controllers, added labels to distinguish whether the view controllers are loaded properly. Also, the starting point of the controller which is decided based on the flag Is initial View Controller can be also achieved by dragging the pointed arrow that indicates that thesis the initial scene to the controller that is required. In this case, just dragged that to the Tab View Controller and thats all i had to do. 

Also understood that the Container view controllers which are displayed are not really acted upon but we need to do on the child view controllers. Also, it looks like Xcode already provides a templates project which helps to create the tab bar controller project. 


As per the instructions in the site, changed the View controllers from the Tab bar view and replaced it with the TableViewController. After this selected Editor -> Embedded In Navigation controller. Embedding inside the navigation controller gave a navigation bar. The navigation bar is a simulated one and it is not a real UINavigation navigation bar. On the navigation view controllers attribute inspector will show the simulated metrics. All of the items such as size, Orientation, Status bar, Top bar, Bottom bar will show the value as Inferred. To add segue between Tab view controller and the navigation controller, the tutorial was suggesting to do a ctrl+drag, which did not work, and hence right clicked and then added the segue manually, and this worked. When added the segue, a tab was created at the bottom and it shown as Item. 

After all these, till now, my storyboard looked like this. 


Wednesday, December 3, 2014

WatchKit Programming - Learning Part 1


The idea of Apple Watch is that instead of pulling the iPhone out of pocket, users can glance though the important information looking at their watch.

Just including a nice picture of the Apple Watch here. Courtesy is Apple web site in references:



There are two parts in an Apple Watch Application, A Watch app that runs in the user’s device and a Watchkit extension which runs in the users paired watch. 
These two are bundled together same like a normal regular extension and when the app is installed, it will prompt the user whether or not the watch kit extension to be 
installed on the paired watch. 

The Watch app contains only the storyboards and resource files associated with the app’s user interface. The watch kit extension contains the code for managing the watch app’s user interface and responding to user interactions. 

Below are the different types of interactions we can support on Apple Watch: 

- The Watch app contains apps full user interface.  The user launches the app from the Homescreen and uses the app view to manipulate the data 
- A Glance is an optional user interface that actually not required to be used in the app, but if present it is a good way to provide timely access to the data. 
- Custome Notification interfaces can be used by the app to alter the default ui in which the notifications are displayed and add custom Graphics, images etc. 

The WatchKit extension is the brains of the Application. Because WatchKit extension runs in the iPhone, it can request location updates and perform long running tasks etc.  

A Glance is a focused interface for presenting important notifications that user needs right now. Glances do not scroll, so the glance ui should fit exactly in one screen. Glances are read only and cannot have actionable ui elements such as buttons, switches or other interactive buttons. Tapping the Glance launches the Watch App. Logic for glances reside in the Watchkit extension. 

The notifications are customisable in the Watch Kit extension. Apple Watch initially displays a minimal version of the UI for the notification. When user interact with the notification, it changes to a detailed view. App can supply the graphics for this detailed view. 
apple watch also supports interactive notifications that is supported in the iOS 8.0. This  behaviour is same as the one which is about specifying the category, 

References: