Friday, September 16, 2016

Upgrading to iOS 10

This time, had to download the profile from iOS device. I chose an iPhone 5s for upgrade.

This can be found here https://beta.apple.com/sp/betaprogram/guide

- After installing the profile, it restarted the phone. 
- Visiting the General Settings, > Software updates, it shown download option to update to the latest software
- Select for Download, the download was around 1.6 GB
- After download, it changed to Install now

- Installing did restart the phone and the update was successfully done

Notes from Sails tutorial - Part 1

Below are few benefits of it.

Auto generated API
Database ORM
Inbuilt task runner
Security code
Built-in web sockets in routes.
Unlike MEAN stack, where you need to create API's manually and do same repetitive thing again and again, Sails.js allows you to automatically create skeleton APIs. Just a single command, and you will have block of code generated to get you started.

Additionally, Sails.js provides database drivers for every major database systems such as MySQL, MongoDB, PostgreSQL. Sails.js uses Grunt task runner as the default task runner, and also provides an effective way to manage custom grunt tasks.

Furthermore, common security parameters such as CORS and CSRF are already included in Sails.js project. All you need to do is to enable them from respective files and your application is secured with the latest security standards.

Sails.js uses Express to handle HTTP operations and Socket.io to handle web socket messages. It provides web socket messages to your routes without configuring it in back-end or front-end layer.

The controllers and model folders are the most important. Controller contains every piece of the code your application needs to drive a backend system and communicate with the View or User interface.

Model contains how the object in data store will look like. So, if you are using a relational database, then it will be a table in database and JSON object in model file, or if you are using NoSQL databases such as MongoDB, then it will be collection under model.

The database connection is configured in config/connections. Since i was planning to use mongo db, it was like below 

someMongodbServer: {
    adapter: 'sails-mongo',
    host: 'localhost',
    port: 27017,
    // user: 'username',
    // password: 'password',
    database: ‘mymongodb’
  } 

user name and password is commented so that it does not ask for any 

in config/model.js, we can configure to use this connection and tell it to sails. 

connection: 'someMongodbServer',


references:

Tuesday, September 6, 2016

iOS how to resign an application

Problems because of the adhoc builds released for internal testing got expired by its provisioning profile? There is a utility to resign such ipa files easily.

iResign is an application which can be downloaded from the link below which helps to do this easily.

As can be seen in the UI, just select the ipa to resign, select the provisioning profile to be used and the Certificate information. Click resign and thats it. it generate the ipa which is ready to be installed again working.

 


Based on experience, it appears that the installation of the signed one fails if don’t give the bundle id at the time of resign.

references:
https://github.com/maciekish/iReSign

iOS Stack View - Working well with Auto layout.

In combination with Auto Layout, one of the most useful tools for working with layouts like the one you have is stack view (UIStackView). A stack view provides a streamlined interface for laying out a collection of views in either a column or a row. Stack views let you leverage the power of Auto Layout, creating user interfaces that can dynamically adapt to the device’s orientation, screen size, and any changes in the available space.

Lets say we have to create a UI like this below 

Lets divide the task into below steps

Step 1: add the UI elements to the scene
just drag 2 labels, 2 text fields and a button to the scene so that it looks below 


Step 2: Embed the UI elements in UIStackView

Shift select all of the added elements and Editor > Embed In > Stack View 

This shows like below 

Step 3: Now align the Stack view to the centre of the screen by using Align and Pin tools 

After the alignment, it will look like the below. 

Step 4 : Align the components within stack view


Select the Text fields individually and add Pin to the edges of the stack view. 

Thats it. the screen is ready. Just change the label to have required text and the background color for the text fields. 

references:

Monday, September 5, 2016

Mac - How to remove the iOS provisioning profiles

This can be done in below 3 steps

1. Navigate to the profiles folder on Mac machine

The profiles are under the directory ~/Library/MobileDevice/Provisioning Profiles

2. Search for profile if any already exist with same bundle id, which could have been already expired or signed with another identity.

The search can be done in the above folder with grep -lr "com.myserver.ppt" *
If the profile exist, this will list the filename(s) having this key.

Now delete the old profile

3. Generate the new profile from developer console and click to install it.

This ensure the Mac is having the latest profile available.
to Note, if the certificate is already expired, then one should install the certificate too, which is by opening the .p12 file that is given to the developer and providing the password to it.

references:
http://stackoverflow.com/questions/26732251/how-to-remove-provisioning-profiles-from-xcode-6-and-xcode-7

Tuesday, August 30, 2016

Android - How to Kill the application on back button press.

The easiest way to do this is to clear all the top activities and call the finish() on the activities. The below code needs to be done by overriding the onBackPressed method.

    Intent intent = new Intent(this, LaunchActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("Exit", true);
    startActivity(intent);
    finish();

On the launch activity, now we need to have the below code at the end of onCreate, note that should not spin any new thread in the OnCreate method.

    if( getIntent().getBooleanExtra("Exit", false)){
        finish();
    }

In some cases, we may not want to have back traces left for specific activity on the activity stack. In such cases, we can just have the below code for each activity in the Android Manifest xml. for e.g. SplashScreen , Login Screen etc.

android:noHistory="true"

One another way is to have the homescreen shown while the app activity is not forcefully finished. The code below should be placed on OnBackPressed overriden method.

Intent a = new Intent(Intent.ACTION_MAIN);
a.addCategory(Intent.CATEGORY_HOME);
a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(a);


references:
http://stackoverflow.com/questions/3226495/how-to-exit-from-the-application-and-show-the-home-screen

Over the Air Profile Delivery concepts

There are three phases involved in this:

1. authentication
2. enrollment
3. device configuration 

Authentication Phase (Phase 1):

Two main aims of this step are

1. Ensure the enrolment request is from valid entity 
2. It captures info about user’s device for use in the certificate enrolment process. 

The steps involved in this are: 

1. User visits the root URL and receives a welcome message. 
2. The user visits the certificate authority URL (/CA) to get the root cert. 
3. The user visits the enrolment URL (/enroll) to start the enrolment process. In this step, user is prompted to authenticate himself or herself using HTTP basic authentication or using existing directory services. 
4. The server’s enrolment handler determines whether the user is allowed to enrol the device. If allowed, server sends a profile service payload. The service payload (.mobileconfig) contains a request for additional device-specific information that device must provide in next step. The payload may include a Challenge token (optional) so that the server can associate the request with the original user. This allows one to customise the configuration process for each user, if desired. 

The device attributes that the service can request are the iOS version, WiFi device ID, product type, phone equipment ID, and SIM card Identifier.  

Certificate Enrolment (X.509 Identities and SCEP) - Phase 2
In the enrolment phase, device contacts the CA and obtains a signed X.509 identify cert, which is used for encryption. 
To acquire an identity, a device first generates an asymmetric key and stores it in its keychain. The secret in this keychain can be read only by that specific device
The device then sends it public key to CA and sends back the signed X.509 certificate. This certificate then combined with the private key on device forms the identify.

The above exchange is possible because iOS supports SCEP. SCEP is a communication protocol that provides a networked front end to a private certificate authority. Support for SCEP is provided by a number of CAs and there are complete open source software of certificate authorities with SCEP support. 

Below are the steps in enrolment phase
1. The user accepts the installation of the profile from phase 1 
2. The device looks up the requested attributes, adds the challenge response (if provided), signs the response using Apple’s built in identity and sends it back to the profile distribution service using POST .
3. The server’s profile request handler sends back a configuration profile that instructs the device to enrol using SCEP.
4. The device Enrolls using SCEP, resulting in a valid identity certificate installed on device. 

Device Configuration and Encrypted Profiles (Phase 3)
This is the phase where the actual profile itself is delivered. The profile that is delivered will be customised for the requested device. To provide protection, iOS allows to encrypt the profile so that they can be installed only on single device. 
An encrypted profile is just like a normal profile except the configuration profile is encrypted with the public key associated with the device’s X.509 identity. 

For encryption and and signing, iOS uses the Cryptographic Message Syntax (CMS) a standard that is also used in S/MIME. Payloads are encrypted using PKCS#7 enveloped data. Profiles are signed using PKCS#7 signed data. 

The steps in the device configuration phase are: 

1. The device sends a signed request for the /profile handler again to request the final profile. The request is signed with the identity certificate obtained in the previous step. 
2. The server profile handler sends the final encrypted profile to the device. 

references:

Friday, August 5, 2016

Android, ImageView Does not fill the parent

Below needs to be done so that the ImageView scales appropriately. scaleXY is important 
<imageview android:id="@+id/image_tag&#8221; android:layout_width=" android:layout_height="wrap_content" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:src="@drawable/bg_image&#8221; android:scaleType=" fill_parent="" fitxy=""> </imageview>




references:

Tuesday, July 19, 2016

iOS Unit Test case

Below are some of the disadvantages

More code: In projects with high test coverage it’s possible to have more test code than functional code.
More to maintain: When there is more code, there is more to maintain.
No silver bullet: Unit tests don’t (and can’t) ensure that your code is free of bugs.
Takes longer: Writing tests takes time — time you could spend learning new exciting stuff on raywenderlich.com!

Below are some of the advantages however

Confidence: You can demonstrate that your code works.
Quick feedback: You can use unit tests to quickly validate code that is buried many layers deep in your app navigation — things that are cumbersome to test manually.
Modularity: Unit tests help keep you focused on writing more modular code.
Focus: Writing tests for micro features keep you focused on the small details.
Regression: Be sure that the bugs you fixed stay fixed — and aren’t broken by subsequent fixes.
Refactoring: Until Xcode gets smart enough to refactor your code on its own, you’ll need unit tests to validate your refactoring.
Documentation: Unit tests describe what you think the code should do; they serve as another way to document your code.


references:

Monday, July 18, 2016

iOS Localization

Normally, below are the items localized

The text in the storyboards
The cover image
The dynamic message displayed by code
The name of the app as displayed in home screen

The "Message" given here is optional. "BOOK_PURCHASE" is checked in the Localizable string and they are substituted here. If not found, "BOOK_PURCHASE" itself will be displayed. 

- (IBAction)buy:(id)sender
{
    [[[UIAlertView alloc] initWithTitle:@"Confirmation"
                                message:NSLocalizedString(@"BOOK_PURCHASE", @"Message")
                               delegate:nil
                      cancelButtonTitle:@"OK"
                      otherButtonTitles:nil] show];
}

references:

iOS Using Unit Tests

Xcode supports three main types of testing. Functional tests focus on code functionality. Performance tests focus on measuring execution time. User Interface tests focus on flows through the user interface. Functional and performances tests are functions that you write. Each function sets up an environment for the test, executes the targeted parts of the app, and tears down the test environment. User interface tests are recordings you make as you use your app.

A test case exercises a unit of code in a specific way or measures a specific part of your app’s performance; if the result of the test is different from the expected result, the test case fails. A test suite is made up of a set of test cases

When you create a project or a target, Xcode includes a unit test target in the scheme that builds the app. The implementation file for the target includes stubs for the setUp, tearDown, and testExample methods. Complete these stub implementations and add other code as necessary to perform unit tests on your app.

references:

Wednesday, July 13, 2016

How Does the AAAA DNS response look like?


It looks like below

Frame 514: 182 bytes on wire (1456 bits), 182 bytes captured (1456 bits) on interface 0
Ethernet II, Src: 00:6c:bc:3c:e3:d6 (00:6c:bc:3c:e3:d6), Dst: Apple_c3:e1:a2 (78:31:c1:c3:e1:a2)
Internet Protocol Version 4, Src: 10.238.35.20, Dst: 10.238.64.113
User Datagram Protocol, Src Port: 53 (53), Dst Port: 49184 (49184)
Domain Name System (response)
    [Request In: 512]
    [Time: 0.007250000 seconds]
    Transaction ID: 0x81b7
    Flags: 0x8180 Standard query response, No error
    Questions: 1
    Answer RRs: 2
    Authority RRs: 0
    Additional RRs: 0
    Queries
        dualstack.pr-my-78232.us-east-1.elb.amazonaws.com: type AAAA, class IN
            Name: dualstack.pr-my-78232.us-east-1.elb.amazonaws.com
            [Name Length: 66]
            [Label Count: 6]
            Type: AAAA (IPv6 Address) (28)
            Class: IN (0x0001)
    Answers
        dualstack.pr-my-78232.us-east-1.elb.amazonaws.com: type AAAA, class IN, addr 9404:ba00:dd00::36b1:9f98
            Name: dualstack.pr-my-78232.us-east-1.elb.amazonaws.com
            Type: AAAA (IPv6 Address) (28)
            Class: IN (0x0001)
            Time to live: 59
            Data length: 16
            AAAA Address: 9404:ba00:dd00::36b1:9f98
        ddualstack.pr-my-78232.us-east-1.elb.amazonaws.com: type AAAA, class IN, addr 9404:ba00:dd00::36b1:9f97
            Name: dualstack.pr-my-78232.us-east-1.elb.amazonaws.com
            Type: AAAA (IPv6 Address) (28)
            Class: IN (0x0001)
            Time to live: 59
            Data length: 16

            AAAA Address: 9404:ba00:dd00::36b1:9f97

Tuesday, July 12, 2016

Running a Sails App - Installing dependancies

When trying to start a Sails App, it resulted in below few errors

module.js:327
    throw err;
    ^

Error: Cannot find module 'request-promise'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)


This appeared to be because some of the modules are not installed. This could get resolved by installing packages 
using the commands such as below 

npm install request-promise


references:

iOS 10 CallKit

In iOS 10, Callkit gives permission to integrate VOIP (voice over internet protocol) apps with the iPhone user interface, therefore user can give answer of VOIP app on iPhone lock screen as well as view contacts of VOIP app in the phone app’s favorites and recent views. 

Apple has given a SpeakerBox Example app as a reference to implement this, which is here


references

Sunday, July 10, 2016

Anatomy of a Sails app

API folder : This folder contains the vast majority of your app's back-end logic. It is home to the 'M' and 'C' in MVC Framework.

Controllers: Controllers contain most of the back-end logic for your app.
Models: Models are the structures that contain data for your Sails App.
Policies: Policies are typically used to authenticate clients and restrict access to certain parts of your app.
Responses: Server response logic (404 - Not Found, 500 - Server Error, etc)
Services: Services are similar to controller actions. They contain logic that used by your app that doesn't necessarily rely on .req() and .res().

references:

What is Amazon SES

Amazon Simple Email Service (Amazon SES) is a cost-effective email service built on the reliable and scalable infrastructure that Amazon.com developed to serve its own customer base. With Amazon SES, you can send transactional email, marketing messages, or any other type of high-quality content to your customers. You can also use Amazon SES to receive messages and deliver them to an Amazon S3 bucket, call your custom code via an AWS Lambda function, or publish notifications to Amazon SNS. With Amazon SES, you have no required minimum commitments – you pay as you go, and you only pay for what you use.

references:



What is Amazon SNS?

Amazon Simple Notification Service (Amazon SNS) is a web service that coordinates and manages the delivery or sending of messages to subscribing endpoints or clients. In Amazon SNS, there are two types of clients—publishers and subscribers—also referred to as producers and consumers. Publishers communicate asynchronously with subscribers by producing and sending a message to a topic, which is a logical access point and communication channel. Subscribers (i.e., web servers, email addresses, Amazon SQS queues, AWS Lambda functions) consume or receive the message or notification over one of the supported protocols (i.e., Amazon SQS, HTTP/S, email, SMS, Lambda) when they are subscribed to the topic.




When using Amazon SNS, you (as the owner) create a topic and control access to it by defining policies that determine which publishers and subscribers can communicate with the topic. A publisher sends messages to topics that they have created or to topics they have permission to publish to. Instead of including a specific destination address in each message, a publisher sends a message to the topic. Amazon SNS matches the topic to a list of subscribers who have subscribed to that topic, and delivers the message to each of those subscribers. Each topic has a unique name that identifies the Amazon SNS endpoint for publishers to post messages and subscribers to register for notifications. Subscribers receive all messages published to the topics to which they subscribe, and all subscribers to a topic receive the same messages.

references:

Saturday, July 9, 2016

Installing Sails on Mac

First ran the command 
sudo npm -g install sails 

after the sails framework is installed successfully, 

Run the command to create a test project 
sails new testProject

This created the below directory structure 

api => This contains directories such as controllers, models, policies, responses, services. In this only policies and responses contain some of the default information. 
assets => This folder contained js, favicon.ico, images, styles, templates, robots.txt  
config => Config contained lot of files, this seems to be the config files for the APIs which applications can use. For e.g. policies.js, socket.js http.js etc
node_modules => This seems to contain the library files 
tasks => 
views 
app.js
Gruntfile.js
package.son
README.md

After this, just had to run the command 
sails lift 

the above command needs to be run from the same directory as the project root, in this case “testProject” 

Now by default, this brings up the server on the port 1337 accessible like below 
http://localhost:1337/

references:

Google Powerpoint How to rotate text?

To rotate the text, basic idea is to create a shape, and add text inside and rotate the shape itself
this rotate shape can be put inside the actual content and can be placed. 

references:

What is Sails

Sails is, of course, a web framework. But take a step back. What does that mean? Sometimes, when we refer to the "web", we mean the "front-end web." We think of concepts like web standards, or HTML 5, or CSS 3; and frameworks like Backbone, or Angular, or jQuery. Sails is not "that kind" of a web framework. Sails works great with Angular and Backbone, but you would never use Sails instead of those libraries.

On the other hand, sometimes when we talk about "web frameworks", we mean the "back-end web." This evokes concepts like REST, or HTTP, or WebSockets; and technologies like Java, or Ruby, or Node.js. A "back-end web" framework helps you do things like build APIs, serve HTML files, and handle hundreds of thousands of simultaneous users. Sails is "that kind" of web framework.

Loose coupling with Sails 
Sails allow us to pick and choose the components that fit our requirements. In fact, it’s just plain lazy to create things any other way. Sails’s approach is to loosely couple components so that they can be added or subtracted from your app at will. Node at its core has created a “can do” culture eager to experiment and make things work. 

Sails accomplishes this loose coupling using plain-old require. No magic, other than the time to craft components that can be part of the whole but don’t need to be present in order for the whole to work. For example, controllers, models, and configuration files are just Node modules. Sails uses some convention to help.

Sails picks up on the name UserController.js in the Controllers folder to deduce that this is indeed a user controller. Another example involves policies. So policies allow you to have a bit of code that executes on controller or specific controller action. The cool part is that the configuration file that connects the policy with the controller/action are separate. That means you can write a bunch of different policies and they are completely portable between Sails apps.

Almost every component of Sails can either be omitted, overwritten, or extended. For example, Sails has a group of tools called blueprints. These blueprints make it really easy to get a project up and running with regard to routes and CRUD operations. But suppose you want to use the read, update, and delete operations but the create action needs some tender loving care. No problem, just build a create action and the other CRUD operations keep working. Your custom action subs in for the blueprint action. It’s just that simple. 

That Simple?  I would need to try this! 

references:

Wednesday, July 6, 2016

Android Audio Focus notes

Every app that plays audio must get the audio session before playing the audio 

for this the code is as below 

private void requestAudioFocusAndStartPlayer(boolean isResume)
{
    abandonAudioFocus();
    mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
    if(mAudioManager  != null)
    {
        int result = mAudioManager.requestAudioFocus(this,AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
        if(result != AudioManager.AUDIOFOCUS_REQUEST_GRANTED)
        {
            Log.i(TAG,"Audio Focus request not granted result:"+result);
            stopPlayer();
        }
        else
        {
            if(isResume) {
                resumePlayer();
            }
            else
            {
                startPlayer();
            }
        }
    }
}

references:

Monday, July 4, 2016

El Captain - Do not see NAT 64 option?

It seems that we have to press Option Key while pressing Internet sharing when selecting the Sharing panel options on the left hand listing. 
On Windows keyboard, this seems to be Ctrl Key. With this, the NAT64 check box appear below the window. 

Btw, this option does appear only on El captains and not anything below this. 

references:

Sunday, July 3, 2016

Android Crash View not attached to window manager

java.lang.IllegalArgumentException: View not attached to window manager
at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:355)
at android.view.WindowManagerImpl.updateViewLayout(WindowManagerImpl.java:191)
at android.view.Window$LocalWindowManager.updateViewLayout(Window.java:428)
at android.app.Dialog.onWindowAttributesChanged(Dialog.java:596)
at android.view.Window.setDefaultWindowFormat(Window.java:1013)

This looks to be because dismissing say a dialog which is not attached to Window yet. 

Below was the solution 

if(dialog != null && dialog.isShowing())
{
dialog.dismiss();
}

references:

Using Whats app web

This was pretty easy, Just select Whats App Web from the phone Whats app app
scan the QR Code, and then on the web page, the whole conversations appear! 

references:

Thursday, June 16, 2016

Siri and Maps interact with your app’s services through two different types of extensions:

To support SiriKit, you use the Intents framework and Intents UI framework to implement one or more extensions that you then include inside your iOS app.

We can add SiriKit if and only if app supports any of the following. These are called domains.

Audio or video calling
Messaging
Payments
Searching photos
Workouts
Ride booking

Siri and Maps interact with your app’s services through two different types of extensions:

An Intents extension communicates your app’s content to Siri and Maps and performs the tasks associated with any supported intents.
An Intents UI extension provides a custom interface for your content within the Siri or Maps interface. This extension is optional.

Siri handles the language processing and semantic analysis needed to turn the user’s spoken requests into actionable intents that your extensions can handle. Siri and the Maps app manage all user interactions and display the results to the user using a standard system interface. Your role is primarily to provide the data to display. If your app includes an Intents UI extension, you can also provide a custom interface to supplement the default system interface.

Ride booking and restaurant reservations are handled primarily by the Maps app, although users can also book rides using Siri. Your Intents extension handles interactions that originate from the Maps app in the same way it handles requests coming from Siri. If you customize the user interface, your Intents UI extension can configure itself differently depending on whether the request came from Siri or Maps.

Creating intents extension

The entry point of your Intents extension is the INExtension object, whose sole job is to direct Siri to the objects capable of responding to user requests. When implementing an Intents extensions, there are three types of objects that you use regularly:

An intent object defines the user’s intent and contains the data that Siri gathered from the user.
A handler object is a custom object that you define and use to resolve, confirm, and handle an intent.
A response object is a data object containing your response to an intent.
When there is an intent for your extension to handle, Siri asks your INExtension object for an object capable of handling that intent. A handler object can be any type that you want, but it must implement the specific methods needed to handle the given intent. Each intent has an associated protocol that its handler must adopt. The methods of this protocol are divided into three groups: resolution methods, confirmation methods, and handling methods. We need to implement the methods you need and provide Siri with information about how you plan to handle the intent.

references:

https://developer.apple.com/library/prerelease/content/documentation/Intents/Conceptual/SiriIntegrationGuide/index.html

Wednesday, June 15, 2016

iOS 10 few new features overview

Apple TV remote app

this is an app on users iPhone with the same capabilities as the Siri remote.
The app uses touch, voice to control Siri, and motion controls for playing games. You can enter text with the regular keyboard.

Another new feature bridging the gap between tvOS and iOS is the automatic download of apps across your devices. Download, for example, the MLB app on your iPhone and it automatically gets installed on your Apple TV as well.

Extending its Continuity effort to make it easier to work across Apple devices, the company also introduced a new Universal Clipboard, which was greeted with exuberant whoops and cheers. Basically, snippets of text, hyperlinks, and the like that you copy on one iOS or macOS device will be available on all the others

 A new "Raise to wake" feature will, as the name suggests, wake the phone's lock screen when it's lifted to give you an overview of notifications and updates. The new notifications look significantly different and, with the use of a 3D Touch, you can respond to and interact with the app sending them immediately. This is very much in line with what Google's been doing with Android.

 The expansion of 3D Touch on the home screen includes widgets for apps that don't require you launching the app at all. You'll be able to see things like the latest sports scores with the ESPN app, and even get into video highlights, without entering the app proper.

- Apple is opening up Siri to developers. Now you'll be able to ask things like "send a WeChat to Nancy saying I'll be five minutes late." That brings up an interface to interact with WeChat directly. Supported apps already include Slack, WeChat, and WhatsApp for communication, as well as Uber, Didi in China, Runtastic, Runkeeper, MapMyRun, and Skype (among others) for VoIP calls.

- Siri now has more contextual awareness. It makes intelligent suggestions based on your current location, calendar availability, contact information, recent addresses, and more. It's Siri growing more and more into the role of an AI or a bot. And yes, it's based on deep learning just like Google's rival system is.

Also based on deep learning is a major update to the Photos app that adds new object and scene detection for powerful search and sorting on your device. All the AI is local to the device, Apple is keen to stress. The phone will cluster together photos that are most relevant at any moment — trips, photos of the last weekend or last year. It can then automatically edit together highlight reels of particular trips or events. It's just like HTC's Zoe photos

Apple Maps is getting an all-new design in iOS. Eddy Cue says the new Maps is "a lot more proactive." Rather like Siri and Photos already are: a lot more predictive stuff being introduced. Maps, like Siri, is being opened up to developers, who can now make use of its extensions. That will allow you to book and pay for a restaurant, book and pay for a Uber ride, and then track your ride, all without leaving the Maps app.

Apple Music is also getting in on the refresh fun with "a redesign from the ground up." Eddy Cue says the new, simpler interface makes the music king, implicitly acknowledging that the old UI was a tiny bit convoluted

Apple Home is the first major all-new app today. It builds on Apple's HomeKit infrastructure to let you manage and control all your connected and compatible accessories around the home. HomeKit is now also built right into Apple's swipe-up Control Center, so it can be accessed even from your iPhone's lock screen. 

The Phone app on the iPhone is also evolving, In iOS 10, it will have voicemail transcriptions so that you can see what messages have been received without having to listen to them. Additionally, the app can now detect when an unknown caller is potentially phone spam and will label those calls as such.


- Messages is the most frequently used app on iOS. It's getting rich links in the new iOS version, allowing things like videos to play right in line inside the message. Emoji have been made three times bigger and, much to the crowd's delight, Apple is going to highlight "emojifiable" words, which you'll be able to just tap and automatically turn into emoji.Messages is also getting bubble effects, which are just cute animations when displaying messages. Apple Music is integrated into Messages — can play a track right in line. And just like Maps and Siri, Messages are being opened up to developers with iMessage apps


references:

Sunday, June 12, 2016

UIImagePickerController - why does it show black area at the bottom?

The reason for this is because the aspect ratio of camera and the screen is different. for e.g. 4:3 while of the screen is 3:2. To fill in the screen, the picture from camera needs to be cropped to the aspect ratio of screen. To dynamically compute it, below is the code.


    self.picker = [[UIImagePickerController alloc] init];
    self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
    self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
    self.picker.showsCameraControls = NO;
    self.picker.navigationBarHidden = YES;
    self.picker.toolbarHidden = YES;
   self.picker.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight) / 2.0);
    self.picker.cameraViewTransform = CGAffineTransformScale(self.picker.cameraViewTransform, scale, scale);

    

references:
http://stackoverflow.com/questions/2674375/uiimagepickercontroller-doesnt-fill-screen

Wednesday, June 1, 2016

Why Does the Apple Watch App Fails to launch on the real hardware?

A lot of threads about this and below is my finding

First of all, the OS version on the Watch was 2.0 and the Xcode was supporting 2.1 OS version. Now, by default the Watchkit App target will be created with the Deployment target as 2.1. If forget about this and try to install the app on the hardware, it will fail to install complaining the version number. Go ahead and change it only in the Watch App deployment target to 2.0 and it will get installed successfully on the device. Now try to launch, it will keep spinning forever. Come back to the Xcode and change the deployment target of the Extension to 2.0 and again install and try to launch. Yep, That launches the app successfully with the interface controller shown.

It was just about the deployment target that caused this issue for me.

references:
http://stackoverflow.com/questions/31489920/apple-watch-app-stuck-loading-shows-a-spinning-wheel-on-real-device

iOS How to code sign without paid account?

We need to first enroll so that get a non paid personal ID https://developer.apple.com/programs/enroll/ 
Once enrolled, This can be give in the accounts area in the Xcode app under preferences. With this done, 
trying to login again will let one to install the app on the device. However, first time the launch will fail because it is not trusted yet.
Trust the profile under settings and now we can launch the app and debug directly on the device. 

Seven years after the inception of the App Store, Apple has finally introduced the new version of Xcode, Xcode 7, which will allow you to deploy and run any number of apps on any of your devices, simply by logging in with your Apple ID. You will no longer need a paid Program membership (and you certainly no longer have to jailbreak your device if you're not comfortable doing so).

Well, not for the majority of use cases anyway. For obvious reasons, certain capabilities and entitlements that require Program membership such as Game Center and in-app purchases will not be available to apps deployed using this method. From Apple's developer documentation:
                                                                                                                                                                    Launch Your App on Devices Using Free Provisioning (iOS, watchOS)

If you don’t join the Apple Developer Program, you can still build and run your app on your devices using free provisioning. However, the capabilities available to your app, described in Adding Capabilities, are restricted when you don’t belong to the Apple Developer Program.
                                                                                                                                                                    The precise steps to getting your app onto your iOS device or Apple Watch follow immediately thus (screenshots omitted for ease of skimming):

In Xcode, add your Apple ID to Accounts preferences, described in Adding Your Apple ID Account in Xcode.

In the project navigator, select the project and your target to display the project editor.
                                                                                                                                                                    Click General and choose your name from the Team pop-up menu.Connect the device to your Mac and choose your device from the Scheme toolbar menu.

Below the Team pop-up menu, click Fix Issue.

 Xcode creates a free provisioning profile for you and the warning text under the Team pop-up menu disappears.

Click the Run button.

Xcode installs the app on the device before launching the app.

Prior to Xcode 7, a Program membership was indeed required in order to sign the provisioning certificates required to deploy apps to devices. The only other alternative was jailbreaking. With Xcode 7, you no longer need to jailbreak your device just to run apps distributed outside the App Store, or to test apps if you cannot afford to join the Program, or to deploy and use apps that you have developed for your own personal use if you do not intend to distribute them through the App Store (in which case you probably don't need the entitlements offered by Program membership anyway).


reference:

Tuesday, May 31, 2016

Migrating Objective C code to Swift


Migration provides an opportunity to revisit an existing Objective-C app and improve its architecture, logic, and performance by replacing pieces of it in Swift. For a straightforward, incremental migration of an app, you’ll be using the tools learned earlier—mix and match plus interoperability. Mix-and-match functionality makes it easy to choose which features and functionality to implement in Swift, and which to leave in Objective-C. Interoperability makes it possible to integrate those features back into Objective-C code with no hassle.

The most effective approach for migrating code to Swift is on a per-file basis—that is, one class at a time. Because you can’t subclass Swift classes in Objective-C, it’s best to choose a class in your app that doesn’t have any subclasses. You’ll replace the .m and .h files for that class with a single .swift file. Everything from your implementation and interface goes directly into this single Swift file. You won’t create a header file; Xcode generates a header automatically in case you need to reference it


Below are the steps

1) Create a Swift class for your corresponding Objective-C .m and .h files by choosing File > New > File > (iOS, watchOS, tvOS, or OS X) > Source > Swift File. You can use the same or a different name than your Objective-C class. Class prefixes are optional in Swift.
2) Import relevant system frameworks.
3) Fill out an Objective-C bridging header if you need to access Objective-C code from the same app target in your Swift file.
4) To make your Swift class accessible and usable back in Objective-C, make it a descendant of an Objective-C class. To specify a particular name for the class to use in Objective-C, mark it with @objc(name), where name is the name that your Objective-C code uses to reference the Swift class.

references:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/Migration.html

Swift Mid And Match



Swift’s compatibility with Objective-C lets you create a project that contains files written in either language. You can use this feature, called mix and match, to write apps that have a mixed-language codebase.

To import a set of Objective-C files in the same app target as your Swift code, you rely on an Objective-C bridging header to expose those files to Swift. Xcode offers to create this header file when you add a Swift file to an existing Objective-C app, or an Objective-C file to an existing Swift app.

If you accept, Xcode creates the header file along with the file you were creating, and names it by your product module name followed by adding "-Bridging-Header.h". (You’ll learn more about the product module name later, in Naming Your Product Module.)

Alternatively, you can create a bridging header yourself by choosing File > New > File > (iOS, watchOS, tvOS, or OS X) > Source > Header File.

In your Objective-C bridging header file, import every Objective-C header you want to expose to Swift. For example:
#import "XYZCustomCell.h"
#import "XYZCustomView.h"
#import "XYZCustomViewController.h"

references:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

Apple Watch - How to it behaves on receiving phone calls





If someone calls you while you're wearing your Apple Watch (and it's paired to your iPhone), you'll be alerted by a subtle vibration as well as an audible ringtone if you haven't set the device to silent.

Look at your watch and you'll see who's calling, along with an answer or decline button. If it's someone you want to talk to, tap the green answer button. There's a built-in speaker and microphone, so you'll be able to chat without getting your iPhone out of your bag or pocket.

Should you wish to take the phone call on your iPhone (don't forget that everyone else will be able to hear your conversation if you're speaking through your wrist unless you're using a Bluetooth headset), you can seamlessly transfer the call from the Apple Watch to your iPhone by scrolling up using the Digital Crown and tapping 'Answer on iPhone.'

references:
http://www.macworld.co.uk/how-to/apple/guide-phone-calls-on-apple-watch-3607555/

Apple Watch handling Notification actions

First of all, we need to create categories

    UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init];
    acceptAction.identifier = @"ACCEPT_IDENTIFIER";
    acceptAction.title = @"Accept";
    acceptAction.activationMode = UIUserNotificationActivationModeBackground;
    acceptAction.destructive = NO;
    acceptAction.authenticationRequired = NO;
    
    UIMutableUserNotificationAction *rejectAction = [[UIMutableUserNotificationAction alloc] init];
    rejectAction.identifier = @"REJECT_IDENTIFIER";
    rejectAction.title = @"Reject";
    rejectAction.activationMode = UIUserNotificationActivationModeBackground;
    rejectAction.destructive = NO;
    rejectAction.authenticationRequired = NO;
    
    UIMutableUserNotificationCategory *notificationCategory = [[UIMutableUserNotificationCategory alloc] init];
    notificationCategory.identifier = @"CALL_NOTIFICATION_CATEGORY";
    [notificationCategory setActions:@[acceptAction,rejectAction]forContext:UIUserNotificationActionContextDefault];
    
    NSSet *categories = [NSSet setWithObjects:notificationCategory, nil];
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:categories];
    

    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];

Now on the App Delegate of the companion app, can override the method


- (void)application:(UIApplication *) application handleActionWithIdentifier: (NSString *) identifier forLocalNotification: (NSDictionary *) notification completionHandler: (void (^)()) completionHandler {

if ([identifier isEqualToString: @"ACCEPT_IDENTIFIER"])
        {
            NSLog(@"Accept is pressed");
            OngoingCallScreen *callScreen = [OngoingCallScreen sharedScreen];
            NSArray *callSessions = [callScreen getActiveCalls];
            NSLog(@"Call Sessions Are :%@",callSessions);
            if([callSessions count] > 0)
            {
                [callScreen handleCallEvent:CallEventToAnswerIncomingCall with:[callSessions objectAtIndex:0]];
            }
            
        }
        else
        {
            NSLog(@"Reject is pressed");
            OngoingCallScreen *callScreen = [OngoingCallScreen sharedScreen];
            NSArray *callSessions = [callScreen getActiveCalls];
            NSLog(@"Call Sessions Are :%@",callSessions);
            if([callSessions count] > 0)
            {
                [callScreen handleCallEvent:CallEventToRejectIncomingCall with:[callSessions objectAtIndex:0]];
            }
        }
   completionHandler();
}

references:
https://developer.apple.com/library/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/BasicSupport.html#//apple_ref/doc/uid/TP40014969-CH18-SW1