Thursday 30 November 2017

How To Implement Deep Linking on iOS



There are surely commonly when your association would need to empower profound connecting. Let's assume you need to partner or pass certain duties then onto the next application, or you have constructed a suite of utility applications starting with you need to coordinate a client starting with one application then onto the next application, going in particular data in a logically delicate manner.
 Possibly you need to empower clients to explore from a contact in your application specifically to his or her LinkedIn profile. Without a doubt, you could simply give a URL, yet that would raise a program with the Web variant of the application rather than the local LinkedIn application. With profound connecting, designers can set up applications so they logically divert a client to an exact area in another application. This is done through the wrapping of a Uniform Resource Identifier (URI) that weds a certain area address, designed like:

facebook://profile/programmableweb

The thought is to embody indispensable data in an ascertained and purposeful approach to permit outer applications (or even Web pages) to open up another local application and present the particular area inside the application that the URI alludes to. This relevant arrangement gives a path around the shut environment in stages like iOS, and more noteworthy cross-application mix.

Android has upheld profound connecting for a long while, and Android's Chrome program list items even profound connect to certain applications.

Application Links By Facebook

Application Links is a profound connecting standard by Facebook that superseeds the organization's expostulated Deep Linking with iOS. Increasing wide group consideration on account of the sponsorship of Facebook, App Links takes into account content, regardless of whether in a Facebook Feed or another App Links-empowered application, to hop specifically to a particular area inside the application.

The above delineates the work process, whereby a man for example would see your substance on a Facebook channel (or another application or even a Web page), which has a given App Link meta-information.

1.            The client chooses the App Link meta-information;

2.            Facebook looks into the substance (or, on the off chance that it is a site page, including some additional metadata) and figures out what application ought to be propelled through a registry Facebook keeps up for open web urls.

3.            Facebook at that point dispatches your application with the logical information added (i.e., particular profile or some other area data) to stack content specifically. On the off chance that the client has not introduced your application, it would then load a Web page.

Beginning with AppLinks

For our case we will allude to an AppLink from one of our Web pages that we have. Along these lines, inside the header, an imaginary ProgrammableWeb application, we would enlist in the header the meta information as takes after:

<head>

<meta property="al:ios:url" content="programmableweb://news/1331"/>

<meta property="al:ios:app_store_id" content="44492821"/>

<meta property="al:ios:app_name" content="PPW for iOS App"/>

<meta property="og:title" content="ProgrammableWeb News"/>

</head>

In the main line above, you can see we are alluding to a particular connection:

programmableweb://news/1331

Inside our invented iOS application, we would have characterized the url in the .plist record, yet in the event that the client hasn't introduced the application, it would fall back to the url/news/1311, which was gotten from the programmableweb://news/1331 meta-information.

For the individuals who don't have a site with Web substance, and subsequently open Web URLs, there is the alternative of utilizing Facebook's Mobile Hosting API. This enables clients to deal with your App Links; you can begin on iOS by entering the accompanying into twist (in terminal):

twist https://graph.facebook.com/application/app_link_hosts \

- F access_token="APP_ACCESS_TOKEN" \

- F name="ProgrammableWeb for iOS Example" \

- F ios=' [

{

"url" : "programmableweb://news/1331",

"app_store_id" : 44492821,

"app_name" : "PPW for iOS App",

},

]' \

- F web=' {

"should_fallback" : false,

}'

We would recover an id returned in JSON design:

{"id":"xxxx1234"}

You can in this manner recover your new App Links URI through another twist ask for, by going in the id returned in the past advance:

twist - G https://graph.facebook.com/xxxx1234 \

- d access_token="APP_ACCESS_TOKEN" \

- d fields=canonical_url \

- d pretty=true

There's one cool advantage worth specifying: the capacity to modify the fallback to divert clients to the App Store to download your application in the event that they haven't introduced your application and have chosen the profound connection. The client would then get coordinated to the suitable profound connection, with the substance go in, not breaking the engagement chain of occasions.

Your application would get a JSON-encoded information bundle like the accompanying:

{

"target_url": "https://www.example.com/abc.html",

"additional items": {

"fb_app_id": [YOUR_FACEBOOK_APP_ID],

"fb_access_token": "[ACCESS_TOKEN']",

"fb_expires_in": "3600"

},

"referer_app_link": {

"url": "[FACEBOOK_APP_BACK_LINK]",

"app_name": "Facebook"

}

}

You at that point supersede in your AppDelegate class, the application:openURL:sourceApplication:annotation: technique to tweak how you handle the parsed approaching App Link ask. We suggest utilizing for iOS the low-level Bolts Library Framework, which will help with receptive and occasion driven demand administration.

- (BOOL)application:(UIApplication *)application

openURL:(NSURL *)url

sourceApplication:(NSString *)sourceApplication

annotation:(id)annotation {

return [FBAppCall handleOpenURL:url

sourceApplication:sourceApplication

fallbackHandler:^(FBAppCall *call) {

BFURL *parsedUrl = [BFURL URLWithInboundURL:url sourceApplication:sourceApplication];

on the off chance that ([parsedUrl appLinkData]) {

/this is an applink url, handle it here

NSURL *targetUrl = [parsedUrl targetURL];

[[[UIAlertView alloc] initWithTitle:@"Received interface:"

message:[targetUrl absoluteString]

delegate:nil

cancelButtonTitle:@"OK"

otherButtonTitles:nil] show];

}

}];

}


Wednesday 29 November 2017

Learn about Java, what it is and why it is so popular


Inside Java offers a glimpse behind the Java platform, and related technologies. In this month's column, I'll show you an overview of the Java programming language.
Java - an island of Indonesia, a type of coffee, and a programming language. Three very different meanings, each in varying degrees of importance. Most programmers, though, are interested in the Java programming language. In just a few short years (since late 1995), Java has taken the software community by storm. Its phenomenal success has made Java the fastest growing programming language ever. There's plenty of hype about Java, and what it can do. Many programmers, and end-users, are confused about exactly what it is, and what Java offers.
Java is a revolutionary language
The properties that make Java so attractive are present in other programming languages. Many languages are ideally suited for certain types of applications, even more so than Java. But Java brings all these properties together, in one language. This is a revolutionary jump forward for the software industry.
Let's look at some of the properties in more detail: -
  • object-oriented
  • portable
  • multi-threaded
  • automatic garbage collection
  • secure
  • network and "Internet" aware
  • simplicity and ease-of-use
Object-oriented
Many older languages, like C and Pascal, were procedural languages. Procedures (also called functions) were blocks of code that were part of a module or application. Procedures passed parameters (primitive data types like integers, characters, strings, and floating point numbers). Code was treated separately to data. You had to pass around data structures, and procedures could easily modify their contents.
                  Java is an object-oriented language. An object-oriented language deals with objects. Objects contain both data (member variables) and code (methods). Each object belongs to a particular class, which is a blueprint describing the member variables and methods an object offers. In Java, almost every variable is an object of some type or another - even strings. Object-oriented programming requires a different way of thinking, but is a
Portable
Most programming languages are designed for a specific operating system and processor architecture. When source code (the instructions that make up a program) are compiled, it is converted to machine code which can be executed only on one type of machine. This process produces native code, which is extremely fast.
Another type of language is one that is interpreted. Interpreted code is read by a software application (the interpreter), which performs the specified actions. Interpreted code often doesn't need to be compiled - it is translated as it is run. For this reason, interpreted code is quite slow, but often portable across different operating systems and processor architectures.
Java takes the best of both techniques. Java code is compiled into a platform-neutral machine code, which is called Java bytecode. A special type of interpreter, known as a Java Virtual Machine (JVM), reads the bytecode, and processes it. Figure One shows a disassembly of a small Java application. The bytecode, indicated by the arrow, is represented in text form here, but when compiled it is represented as bytes to conserve space.


Multi-threaded
If you've ever written complex applications in C, or PERL, you'll probably have come across the concept of multiple processes before. An application can split itself into separate copies, which run concurrently. Each copy replicates code and data, resulting in increased memory consumption. Getting the copies to talk together can be complex, and frustrating. Creating each process involves a call to the operating system, which consumes extra CPU time as well.
A better model is to use multiple threads of execution, referred to as threads for short. Threads can share data and code, making it easier to share data between thread instances. They also use less memory and CPU overhead. Some languages, like C++, have support for threads, but they are complex to use. Java has support for multiple threads of execution built right into the language. Threads require a different way of thinking, but can be understood very quickly. Thread support in Java is very simple to use, and the use of threads in applications and applets is quite commonplace.
Automatic garbage collection
No, we're not talking about taking out the trash (though a computer that could literally do that would be kind of neat). The term garbage collection refers to the reclamation of unused memory space. When applications create objects, the JVM allocates memory space for their storage. When the object is no longer needed (no reference to the object exists), the memory space can be reclaimed for later use. 
Secure
Security is a big issue with Java. Since Java applets are downloaded remotely, and executed in a browser, security is of great concern. We wouldn't want applets reading our personal documents, deleting files, or causing mischief. At the API level, there are strong security restrictions on file and network access for applets, as well as support for digital signatures to verify the integrity of downloaded code. At the bytecode level, checks are made for obvious hacks,
Network and "Internet" aware
Java was designed to be "Internet" aware, and to support network programming. The Java API provides extensive network support, from sockets and IP addresses, to URLs and HTTP. It's extremely easy to write network applications in Java, and the code is completely portable between platforms. Java also includes support for more exotic network programming, such as remote-method invocation (RMI), CORBA and Jini. These distributed systems technologies make Java an attractive choice for large distributed systems.



Swift, iOS, and Threading

Multi strung is a capacity of Processor to execute numerous procedures or string simultaneously bolstered by Operating System.

A Program contains at least two sections that can run simultaneously and each part can deal with various undertaking in the meantime making ideal utilization of the accessible assets.

Threading has a genuine cost in feeling of memory and execution, each string required memory assignment in both Kernel and your program memory space.

Multi threading was presented in iOS 3.2, we have three choices for multi threading in iOS which is given underneath with fundamental subtle elements:

Have you at any point composed an application where you endeavored to accomplish something, and there was a long respite while the UI was inert?

This is generally a sign that your application needs multithreading!

In this instructional exercise, you'll get hands on involvement with the center multithreading API accessible on iOS: Grand Central Dispatch.

You'll take an application that doesn't utilize multithreading by any means (and subsequently is exceptionally inert), and change over it to utilize multithreading. You'll be stunned by the distinction!

This instructional exercise expect you know about the nuts and bolts of iOS advancement. On the off chance that you are totally new to iOS improvement, you should look at a portion of alternate instructional exercises on this site first.

Right away, take a drink of pop or bite some air pocket gum and start this instructional exercise in the meantime – and you're as of now on your approach to multithreading! :]

When taking in another dialect I more often than not take after a similar example. I make sense of how to do parallel preparing, reflection, and fabricate a couple of applications. Here is the start of my investigation of threading in Swift. I'm utilizing NSOperations in this post and will take a gander at GCD in a followup post.

Here are the means:

make another quick document and acquire from NSOperation,

supersede NSOperation's primary technique,

presently make an occasion of your new operation class,

set the string need, and

add it to a NSOperationQueue occasion.

So far not unique in relation to Objective-C.

For this case I will make a Sift class that acquires from NSOperation called BackgroundSillyness. At that point I'll utilize BackgroundSillyness in a Swift application's ViewController viewDidLoad strategy.

Making an occasion of NSOperation:

let line = NSOperationQueue()

BackgroundSillyness.swift source

/import the Foundation library

import Foundation

/acquire from NSOperation

class BackGroundSillyness:NSOperation{

/abrogate NSOperation's void main(void) technique

abrogate func principle() - > (){

println("hello from foundation")

}

So that is the class record. Presently for the source from the ViewController. I'll just incorporate the source from the viewDidLoad technique with a specific end goal to keep things basic. You will perceive some of what is occurring here on the off chance that you know about Objective-C.

ViewController.swift source

supersede func viewDidLoad() {

super.viewDidLoad()

/Create another occasion of BackGroundSillyness

let backgroundOperation = BackGroundSillyness()

/* I chose I needed to make sense of how to supplant hinders with terminations,

* soI set the consummation square of the operation.

* 'hi' will now print outafter 'hi from foundation'.

*/

queue.addOperation(backgroundOperation)

/this is the default esteem, however in the event that you don't set it you will get a mistake.

backgroundOperation.threadPriority = 0

backgroundOperation.completionBlock = {() - > () in

println("hello")

}

}

So there it is. The greater part of alternate properties of NSOperations can be set similarly as the fruition square. You can likewise forget the '()- >() in' bit of the conclusion on the off chance that you need. Quick will induce the information and return sorts for you in the event that you do.

When you run this, you may find that the foundation operation's message is stirred up in the one printed out in the UI string. It gives the idea that Swift doesn't line up messages to the comfort. It isn't an imperfection only brief comment mindful of. You could include a long running circle out of sight operation's primary technique on the off chance that you might want to prevent this from happening.



Tuesday 28 November 2017

iOS Memory Management and Multithreading

 This post contains my perusing notes of the book <Pro Multithreading and Memory Management>, from the systems of ARC to the utilization of Blocks and Grand Central Dispatch.

Memory Management Actions in Objective-C - Reference Counting

Activity for Objective-C Object  Objective-C Method

Make and have responsibility for/new/duplicate/mutableCopy gathering

Take responsibility for

Surrender it        release

Discard it              dealloc

+(id)alloc

implementation.m

+ (id) alloc {

return [self allocWithZone: NSDefaultMallocZone()];

}

+ (id) allocWithZone: (NSZone*)z {

return NSAllocateObject (self, 0, z);

}

struct obj_layout {

NSUInteger held;

};

inline id

NSAllocateObject (Class aClass, NSUInteger extraBytes, NSZone *zone) {

int estimate =/* required size to store the question */

id new = NSZoneMalloc(zone, estimate);

memset(new, 0, estimate);

new = (id)&((struct obj_layout *)new)[1];

}

The NSAllocateObject work calls NSZoneMalloc to apportion a memory territory. From that point forward, the territory is loaded with zero and the range pointer is returned.

Objective-C now disregards zones, which was utilized to avoid memory discontinuity. The alloc technique would now be able to be changed as:

demo.m

struct obj_layout {

NSUInteger held;

};

+ (id) alloc {

int estimate = sizeof(struct obj_layout) + size_of_the_object;

struct obj_layout *p = (struct obj_layout *)calloc(1, estimate);

return (id)(p + 1);

}

The alloc strategy restores a memory piece loaded with zero containing a struct obj_layout header, which has a variable "held" to store the quantity of references(reference tally).

hold

get reference tally an incentive by calling retainCount:

demo.m

id obj = [[NSObject alloc] init];

NSLog(@"retainCount=%d", [obj retainCount]);

/*

* retainCount=1 is shown. */

Execution of hold:

demo.m

- (id) retain{

NSIncrementExtraRefCount(self);

return self;

}

inline void NSIncrementExtraRefCount(id anObject) {

in the event that (((struct obj_layout *)anObject)[-1].retained == UINT_MAX - 1)

[NSException raise: NSInternalInconsistencyException

arrange: @"NSIncrementExtraRefCount() asked to increase excessively far"];

((struct obj_layout *)anObject)[-1].retained++; }

at the point when the variable "held" floods, it's increased.

discharge

demo.m

- (void) discharge {

on the off chance that (NSDecrementExtraRefCountWasZero(self))

[self dealloc];

}

BOOL

NSDecrementExtraRefCountWasZero(id anObject) {

on the off chance that (((struct obj_layout *)anObject)[-1].retained == 0) {

return YES;

} else {

((struct obj_layout *)anObject)[-1].retained- - ; restore NO;

}

}

"held" decremented.

dealloc

demo.m

- (void) dealloc {

NSDeallocateObject (self);

}

inline void NSDeallocateObject(id anObject) {

struct obj_layout *o = &((struct obj_layout *)anObject)[-1];

free(o);

}

a chunck of memory desposed.

autorelease

like "programmed variable" in C, which is discarded consequently when the execution leaves the degree.

autorelease implies when execution leaves a code hinder, the discharge strategy is approached the question naturally.

demo.m

- (id) autorelease {

[NSAutoreleasePool addObject:self];

}

ARC(Automatic Reference Counting)

With ARC, "id" and protest sort factors must have one of the accompanying possession qualifiers:

_strong, _weak, __unsafeunretained, _autoreleasing

Possession is appropriately overseen by factor scope, as well as by assignments between factors, which are qualified with __strong.

Utilize __weak to maintain a strategic distance from roundabout references:

A __weak possession qualifier gives a frail reference. A powerless reference does not have responsibility for protest.

demo.m

id __strong obj0 = [[NSObject alloc] init];

id __weak obj1 = obj0;

/*

* variable obj1 has a feeble reference of the made protest */

_unsafe_unretained: don't utilize it unless you need to help before iOS5, it may leave a dangling pointer. utilize _weak.

Notwithstanding, __weak is only for pointers that ought to be focused, not for primitive sorts.

_unsafe_unretained is valuable for circumstances where you have a protest pointer in a circumstance where ARC doesn't have enough control to securely oversee memory, as within a consistent C struct. That is one reason there's the "no question pointers in C struct" confinement, unless you enrich that point with _unsafe_unretained to tell the compiler you what you're doing. It's likewise used to break solid reference cycles (a.k.a. hold cycles) with obstructs under some particular conditions.

However, for 99.9% of day by day work, feeble works awesome and you can disregard __unsafe_unretained.

Source

Pieces

A Block is created from the Block strict beginning with "^". Also, the Block is relegated to the variable "blk". Obviously you can relegate the incentive to different factors of the Block sort.

Squares are Anonymous capacities together with automatic(local)variables.

Presentations source

As a neighborhood variable:

returnType (^blockName)(parameterTypes) = ^returnType(parameters) {...};

As a property:

@property (nonatomic, duplicate) returnType (^blockName)(parameterTypes);

As a strategy parameter:

(void)someMethodThatTakesABlock:(returnType (^)(parameterTypes))blockName;

As a contention to a strategy call:

[someObject someMethodThatTakesABlock: ^returnType (parameters) {...}];

As a typedef:

typedef returnType (^TypeName)(parameterTypes);

TypeName blockName = ^returnType(parameters) {...};

block.m

int (^blk1)(int) = blk;

int (^blk2)(int); blk2 = blk1;

/*Functions can take contentions of Block type.*/

void func(int (^blk)(int)) {

/*Also, capacities can restore a Block.*/

int (^func()(int)) {

return ^(int count){return check + 1;};

}

Utilizing typedefs:

block.m

typedef int (^blk_t)(int);

Amazing Central Dispatch

The most effective method to utilize: characterize assignments you need to execute and add them to a suitable dispatch line.

GCD.m

dispatch_async(queue_for_background_threads, ^{

/*

* Here, handling a tedious errand

*

* The errand is finished. At that point, utilize the outcome on the primary string as takes after.

*/

dispatch_async(dispatch_get_main_queue(), ^{

/*

* Here, undertakings that work just on the primary, for example,

* refreshing client inteface, and so forth.

*/

});

});

Dispatch Queues

A dispatch line is a line to store undertakings to be executed (in the additional, first in first out request).


Monday 27 November 2017

Most effective method to assemble Selenium-based test automation

The center element of Selenium, the broadly utilized cross-stage, open-source system for web application robotization, is its WebDriver API, which you can use to make test contents in a wide range of programming dialects to keep running on an assortment of programs.
Let’s perceive how to make a Selenium venture and the various techniques for distinguishing application objects while robotizing your application. Basically, Selenium is simply program mechanization.
The toolchain:
A Java library that expands the WebDriver API with extra locators and utilities. Utilizing this library, you can make more vigorous and non-specific IDs for your articles and utilize worked in utilities as opposed to actualizing them on your end starting with no outside help.
An IDE module (for Eclipse and IntelliJ) that gives you:
•          IDE venture layouts for Selenium ventures—using these formats, you can make extends that are prepared for Selenium mechanization in only a couple of snaps.
•          An Object Identification Center (OIC)— An intense spying device that empowers you to proficiently fabricate WebDriver-based protest distinguishing pieces of proof, approve them, and create the recognizable proof code rapidly and effortlessly.
Making Selenium ventures:-
The LeanFT module broadens your IDE with venture layouts that enable you to make Selenium extends by following only a couple of steps:
1. In your IDE, begin making another task (e.g., in Eclipse: select File - > New - > Project). The "New Project" wizard opens.
2. Under the "LeanFT" envelope, select "LeanFT Testing Project."
Snap "Next."
3. At that point:
•          Under "Testing Framework," select the testing structure to use in your undertaking.
•          Under "Mechanization SDK," select "Selenium" and utilize the "Peruse" catch to choose the Selenium library (either the Selenium remain solitary JAR, or the gathering of Selenium Java restricting JAR documents). You can likewise make your task as a Maven venture.
4. Snap "Next," at that point determine your task name and bundle, as you would with some other Java venture. At long last, click "Wrap up."
Another venture will be made:
The made venture consequently incorporates a class record in which you can begin making your test. The arrangement of this class depends on the testing system you chose.
The fundamental bundles required keeping in mind the end goal to work with this system and with the WebDriver API are as of now transported in. A few imports for fundamental classes of the LeanFT Selenium augmentation library (specified above) are incorporated also. Obviously, all the required libraries (the testing system library, the Selenium library, and the LeanFT Selenium augmentation library) are naturally referenced in the venture.
Presently you are prepared to execute your test. Wasn't that simple?
Begin executing your test:-
To execute your test, you'll ordinarily begin by composing Selenium code that dispatches your program and explores to the application under test. For instance, on the off chance that you might want to dispatch Chrome and explore to Google, your code will resemble this:
·         ChromeDriver driver = new ChromeDriver();
·         driver.get("http://google.com");
At that point you will need to compose code that associates with objects in the application, taking consideration to actualize the situation you need to mechanize. Here's the manner by which you do that.
Distinguish your items:-
Suppose you need to computerize the situation of looking in Google. You'll have to compose code that puts some an incentive into Google's pursuit field and taps the "Google Search" catch:
While mechanizing application objects, you have to first make an ID code for these items. The distinguishing proof code is in charge of finding these articles in the application, in view of certain hunt criteria.
Making this ID code isn't generally simple:
·         You need to comprehend your alternatives for recognizing the question.
·         If you know how to recognize it (e.g., the question's component incorporates a "name" quality), you should ensure that this ID is special, coordinating with just a single protest.
·         You must ensure your recognizable proof is hearty, implying that it won't be broken effectively because of changes in the application. Else, you will wind up putting a ton of vitality in keeping your tests pertinent.
About Author:

Learn selenium and become a software testing engineer by joining selenium training in Bangalore. Join Infocampus – a best selenium training institute in Bangalore. At infocampus, trainers are experienced professional and they teach basic and advanced level of selenium training with core java. At the end of training, candidates will get groomed with technical skills. Contact 9738001024 to attend free demo classes to know the quality of teaching. Visit http://infocampus.co.in/best-selenium-testing-training-center-in-bangalore.html for much more details on selenium course.