iPhone and printer integration Sample code/API for custom App development - iphone

My recent engagement demands a printer integration using iPhone. The app will
• Generate a PDF with the collected data
• Print the same when user clicks print button
I am fairly new in iPhone development. There are hardly any reference and sample codes to support the printing feature , however there are quite a few apps available in the market to print from iPhone!
Please help me with reference or sample code to realize the feature from within the custom app we are building.
Many Thanks
-Jeet

I haven't developed an app that supports printing, however, I'm pretty sure the ones that do must be connecting to a companion OS X application running on some computer on the same wifi network that the iPhone app connects to and sends its data to.
This means that you'll have to look at the printing docs and sample code for the Desktop and build a helper app that will receive connections from your iPhone app. There is sample code to show you how to discover a computer on your network using Bonjour. You can then just stream the data over the network using a socket to the Desktop app from the iPhone and have it pass along the print job.
You say that you're fairly new to iPhone development, so this comes with a warning that it's not for the faint of heart.
Here is a blog post on how to communicate between desktop and iPhone using Bonjour:
http://cocoa-nut.de/?p=27
Best Regards,

There is official printing API from Apple. This only support for iOS 4.2 and above though:
http://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/Printing/Printing.html

I am also looking for the same solution as I need to do this for the application that I am working on. I am also generating the PDF and user can then print it.
As you are saying that already developed apps are printing without using intermediate PC. But while searching over the net I came around an application which is useful for printing for Epson
http://mobile.eurosmartz.com/products/print.html
There it is mentioned by the company it self that "Install “Print” on your iPhone, download the free WePrint software for your desktop/laptop computer and then you can print directly from your iPhone."
Also there is another application on iTunes called "PrinterShare- print from iPhone to anywhere". There also they mentioned that computer connected to printer needs the PrinterShare software.
So I think there is a mediator present in these printings.
Let me know if you find some more information on this topic, as this is very new and clients are asking to avail this facility in there applications.
If you come to know any sample application
Regards,
Vishal.

There is currently no Official printing API.
You could of course implement your own LPR printing code.
Or you can license a ready API from someone like www.e-workshop-dev.com

Related

Database driven ios app - first steps

I'm about to start work on my first app which will be an internal release to gather customer information at a trade show.
I'm hopefully looking into using air for ios or maybe one of the various html/js frameworks to develop this app as an alternative to learning C.
ideally I would do it with some server based php > sql to store and share gathered information between a fleet of iPads, unfortunately due to the population of this trade show there will be no guarantee that i can maintain a wireless connection so need to prepare for these apps all being local access only.
in which case, how would you recommend going about the saving/reading of the stored data, and also how to sync it up with a sql server and then back to the iPads each night.
Did you try PhoneGap? It is an HTML5 app platform that allows you to author native applications with web technologies, in other words it will let you make an iphone app without having to learn C.
People have written tutorials and plugins for storing data locally.
PhoneGap basically wraps a web app hence you can use AJAX for sync with server as and when needed. This article might help.
We explored PhoneGap and found it very useful. and easy too. hope this helps you.

How to integrate Juggernaut chat server (Powered by ruby on rails) with iPhone/Android app for real time chat?

Preview:
I am using juggernaut chat server.I am having redis and juggernaut server running on machine. I am able to do chats within my local network on vaious web browsers. Everything is working smoothly. As juggernaut is a server driven chat server so i am quite sure about the scalability thing. Now here is the thing:--
Whats the problem:
I want to have a iphone native app too where user can login and chat with his friends. Now the thing i want to know is how do I push on iphone app, cause for juggernaut client registration a javascript code is needed. Something like this:
var jug = new Juggernaut;
jug.subscribe("channel1", function(data){
alert(data);
});
Basically how do i push new notifications to Iphone chat window. I don't know much about iphone as I am web developer. Still from google search etc I came to know some possible ( may be) ways:-
We can embed a url in iphone window. Is this a good approach?
Other thing we can do is using UrbanAirship kind of services we can do push notifications. Will push notification works for chat? I don't know about that even.
Third option can be polling. Iphone chat client keeps on hitting my rails app for new notifications. But i think this will be a very bad approach.
What are the other possible solutions?
Can any iPhone/Android developer guide me what should i do. I will eventually hire a Iphone developer to do all the coding part. But I want to have a big picture in my mind so that I can provide a complete docs of all the things, and have a clear picture how I want to discuss things with him before writing down the code.
PS: I am looking for a solution which works for android/nokia devices too. Cause later on I will be developing an application for that too. Basically it will be good to have a same solution. if not then compatibility factor should be there atleast.
Apparently there is WebSocket support in MobileSafari on 4.2 (source). You could probably write up a client that uses an embedded UIWebView to marshall the events to/from the Juggernaut server and deliver them to your app via shouldOpenURL and custom handlers.
You might also look at libPusher by Luke Redpath for interacting with push communication via the Pusher web service.
Check out this library: https://github.com/fpotter/juggernaut-cocoa
It's really easy to use.

Want to transfer data on iPhone to a program on a PC

I have an iPhone app that reads barcodes. I want to transfer that data to a program I have written on my PC. Is this possible?
The easiest way to do this is to have a web server which the app transfers the barcode to and the application on the computer grabs it from. You could probably have each user make an account which they log in to on both the phone and the computer.
EDIT: This document: http://developer.apple.com/library/ios/#technotes/tn2152/_index.html describes various methods for transferring data between an iphone and a computer.
This is just a suggestion, haven't tried it myself: You can use the iTunes filesharing feature Apple introduced for iOS. This seems to be a good tutorial on how to use it in your App http://www.raywenderlich.com/1948/how-integrate-itunes-file-sharing-with-your-ios-app
The only thing is that it requires the user to import/export the files to share on their own via iTunes, if you're cool with that it sounds like a good strategy to use built-in features of iOS.

Debugging iPhone App from Command Line

I can do it from XCode, but I want to be able to launch an iPhone App (on the device) from the command line. Is it possible?
Why? Because I want to capture some of the output for semi-automated testing. I'm guessing I need to use a debug build for NSLog output, but I'd also be interested to know about other methods for getting NSLog / stdio data back to the host Mac.
There is a project on github called titanium_mobile (part of Titanium Developer).
I use a utility from that project called iphonesim. It launches an iPhone app from the command line (though I am not sure how, I think there is a way to do that with SpringBoard.app). If you take a step up one level in the Titanium Mobile code and look at builder.py you can see how they launch an app in the simulator and capture the output.
Ultimately I solved my specific need a different way. I needed to get data from the iPhone's accelerometers into a prototype app in Adobe AIR(Flash).
I used this app on the iPhone which drops UDP packets with X,Y,Z forces in them.
http://code.google.com/p/accelerometer-simulator/wiki/Home
Found that from this blog post which might be of interest to people trying to do other similar things.
http://ifiddling.blogspot.com/2009/01/dummy2.html
I used a Python script to present a server to Flash, grab UDP accelerometer packets, munge them into AMF and send them to Flash. Flash uses a socket to connect to this server and receive the accelerometer data.
A few parts, but it works nicely.
You can do this on the device if it is jailbroken. You can put a debug build and symbols on your device and run gdb on it. It is totally unsupported but I hear it works. Not sure if there is a good tutorial. Google?
One method would be to use the AsyncSocket class, and pass whatever data you want to log from the iPhone to a basic host app on the Mac, which NSLogs whatever it receives. If you follow the EchoServer application, you should be able to integrate it in just a few minutes

iPhone: Need suggestion for SYNC contact

i want to create a application which sync my iPhone contacts to my server and vice-versa.
i read a article on google Get Google Sync on your phone . i want to this type of feature which directly update the contact without user interaction (however one time setting is desired).
any body have idea how the google sync work .
Please advice me that how can i achieve this task. any suggestion and link is greatly appreciated
I think it's important to separate the two overlapping approaches in your question.
Firstly, Google Sync is essentially a way to use Microsoft Exchange protocols and to setup a Mail / Contact / Calendar profile on an iPhone. The iPhone OS supports this feature, not an iPhone App in the App Store. Google Sync leverages this fundamental capability of the phone by exposing the data (mail, contacts, calendars) via these known protocols. If you want to expose data in this way to your users, setup a Microsoft Exchange server and ask questions on serverfault.
Secondly, there are iPhone apps. iPhone apps sold in the app store are not currently allowed to run in the background. This means you can't emulate functionality like iTunes or Mail where your music plays while you are browsing the web, or mail checking is done while you are playing a game of Mini Squadron. If you want this backgrounding capability, file a bug/enhancement with Apple.. However, you can interact with iPhone contacts (Address Book) via the API.. You can also of course "re-invent the wheel" and expose the data however you like via the internet, and consume that data from a custom iPhone App with the one caveat that users would need to actively launch your application to get to this data and it would not be integrated with the built-in iPhone Calendar, Address Book or Mail applications. Some good examples of that are some of the music community apps that have messaging systems built into them. Presumably that is all being done with web services.
EDIT: It is also worth mentioning that should you go the "iPhone App" route, you should at least consider if push notifications are right for you, and if so how you will handle it.
Have you seen the API-Docs?
http://developer.apple.com/iphone/library/documentation/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/100-Introduction/Introduction.html
Next there is an application I use called Funambol - it is a sync4j Server/Client. They have an open source application to sync contacts on the iPhone. Source is somewhere in their repository, informations here: http://forge.ow2.org/scm/?group_id=96
As slf told you your application must run in foreground. This may limit you.
Good luck & best regards,
Florian
The 3.0 SDK will allow your application to read contact data on the phone.
Web services will allow you to publish that data to your server, and receive updates.
You may also want to use coredata to store a hash of all contact data so you can tell what is new / updated and just send that data to your server.