Xcode 4.5.2 and iOS 6.0.1 Bonjour Logon with External Java Server

Updated: March 29, 2014 for Xcode 5.1 and iO 7.1

Updated November 24, 2012 to allow Portrait Orientation.

Updated December 3, 2012 to use the AppDelegate instead of a UITableViewController to find Bonjour Servers. Newbound Test Bonjour with ZeroConf Server links to the Xcode 4.5.2 iPad2 iOS 6.0.1 source code version 1.1. See the ReadMe in that Xcode project for updated changes.

Part of the iOS Category.

Xcode templates supplied by Apple and others (such as myself) offer budding programmers a way to improve their programming skills and bring their ideas to fruition.

As I previously wrote in the other pages in this WordPress category, what we budding programmers need are templates that show how to do basic tasks, not complicated tasks. There are already many complex templates and that is fine in itself. Mostly they help more advanced programmers, leaving a large gap to fill by the rest of us.

Too often in many templates and example code, a basic task is embedded inside a complex application, usually written by a very seasoned programmer. As a result the simple task’s understanding is lost on the beginning programmer. There has to be a better way to use Xcode templates as a tool for beginner programmers.

I would love to see iOS Apple Developer Program create a comprehensive collection of basic task templates for all their iOS devices covering most, if not all, of their technologies.

Just show us how to start using your technologies in Xcode, please. 🙂

I ask the same of the thousands of programmers in colleges and universities to also create and share their basic task templates. Provide the Xcode project and source code and further the cause.

I continue to try to create useful Xcode templates for programmers who sought the help I sought and were left wanting. I don’t claim to be the best iOS programmer and I know in some of my Xcode tutorial templates, their may be other better ways to show the basic tasks. But at least my templates are out to help someone.

My free templates are shared as a way to Pay It Forward are downloaded from the Internet in excess of over 120 every day. That may be a very small part of a drop in the ocean, but it’s better than evaporating into thin air.

This tutorial is my way of incorporating Apple’s iOS BonjourWeb template (found on the AppleDeveloper website) into an Xcode iPad2 Master-Detail template. I then also incorporated some UIAlertView code I found on the Internet (by mobile.tutsplus.com) to handle simple external server authorization.

My Newbound, Inc., software partner, Marc A. Raiser, created a very simple HTTP Bonjour Server written in Java to respond to the requests by the iOS 6.0.1 iPad2 app. The Xcode 4.5 project and source code are included and linked to in this tutorial, a few paragraphs down. The Java .jar file for the Bonjour Server is also included further below.

You will need to have Java installed (at least the JRE), and updated for the Mac.

Newbound, Inc., will soon make available on our website a section dedicated with my iOS Tutorials of Xcode projects and source code and Java projects and source code. It’s all part of the company’s Pay It Forward philosophy.

In the Xcode project folder I included a ReadMe document to explain how to use both the iPad2 app and the Java Bonjour Server.

Here are the project and source files for the:

I include some images to provide some insight into the apps:

I run the Newbound ZeroConf Test Server from its enclosing folder on my Desktop. If you run it from another location, update the path to the .jar file in Terminal.

The message in Terminal window below indicates the server is ready. Be sure to quit the server with a Control-C and also perhaps quit Terminal when you are finished running the iPad2 app.

Launch the Xcode project file and run the project in the 6.0 Simulator. The launch image appears briefly.

This app only allows you to connect to the Newbound ZeroConf Test Server and then attempt to authorize your use of the server. It has no other functionality beyond thatThat’s why this tutorial app is only two basic tasks. 🙂

However, if you feel adventurous you may use my other iPad2 templates to evaluate additional features.

Be sure you can connect to the Bonjour Server if it’s running on another computer in the local zone on your network either by direct ethernet connection or WiFi.

On the Portrait Only version 1.1, the app launches directly into the BonjourBrowser code. The iPad2 app looked into the network’s local zone and found the service being broadcast by the Newbound ZeroConf Test Server.

Because the Bonjour Server is broadcasting using the http protocol, it shows up in the local zone along with other http services being broadcast by other Bonjour Servers.

Apple’s BonjourWeb template allows the user to add zones and cancel the search at the Domain view. I found that code had a bug when used in the Master-Detail template. Those capabilities are commented out in this project’s source code.

Don’t try to connect to other services than the zeroconftest service because it will crash the app. Only select the service name beginning with zeroconftest that runs on the computer you have the Newbound ZeroConf Test Server running on.

The iPad2 app in Portrait and Landscape modes version 1.0.1 will finish starting up and appear like this.

In Portrait Only version 1.1:

In version 1.0.1:

Upon selecting that row in the Master UITableView, it will highlight and bring up the UIAlertView to allow beginning the Logon process. At this point the iPad2 has obtained and recorded in a property the url to the Newbound ZeroConf Test Server.

In the UIAlertView enter “admin” in the Login field and “admin” in the Password field. That is the correct combination allowing the Newbound ZeroConf Test Server to authenticate you. Then press the Login button.

You’ll receive the sucessful logon message as shown.

At this point the iPad2 app has obtained and recorded in a property, the sessionID used subsequently to send commands to the server.

Any other entries will cause failure message to be displayed and no sessionID is obtained.

In Portrait Only version 1.1:

After successful logon you are brought to the UITableViewController code.

By clicking the Master button in the upper right the table view itself is displayed.

Take a moment and look at the Terminal window. You’ll see the messages the Bonjour Server posted in analyzing your attempts to logon.

If you now go back to Xcode and look in the Console pane, you’ll see something like this message for successful login attempts.

 

 

 

As a final way to check your login and sessionID you can put actual urls in your browser address bar and press Return. You may obtain the actual urls from the Xcode Console window pane as shown above:

  • The Login test is the string that starts with: The complete url for the login command is:
  • The sessionID test is the string that starts with: The complete url for the sessionID test command is:

When you exit the iPad2 app and look at the Home Screen in Landscape on the Simulator, the app’s icon is present.

When you exit the iPad2 app and look at the Home Screen in Portrait on the Simulator, the app’s icon is present.

Enjoy applying these new skills and if you have some improvements to offer, feel free to send me your project and code or post your project and code on the Internet and send me the link. 🙂

Did you like this? Share it:

About Don Larson

Using computer technology since June 1980.
This entry was posted in iOS, iOS Tutorials, Native Apps, Technology. Bookmark the permalink.