7

I just got done writing an Android Activity that allows other Activities to call it for some result (it's not intended to be a stand-alone Activity). I'm now working on the equivalent iOS application and can't find any resources for how I would enable similar functionality on iOS.

The situation: The tool I'm producing is intended to be used by other applications, rather than as a standalone application. The thing is, the GUI that needs to be presented to the user is rather involved so I'd like to be able to provide the developer with a "all-in-one" package that they can simply launch and get results from. Doing this in Android was very straight forward. I simply wrote an Activity and instructed the developer to launch this Activity for result. I've looked around and can't find a similar functionality to allow an iOS developer to do the same. What would be the best way to go about doing this?


I think part of the problem I'm having in finding resources is that I'm not entirely sure what what I'm making is called. A library? extension? plug-in? I would think a library doesn't have a GUI and it seems extensions and plug-ins are made for an extensible application (that is, one in which the user can install the extension/plug-in).

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Tim
  • 6,265
  • 5
  • 29
  • 24

3 Answers3

2

Your API could be à single call that would pop up a modal view. A target and selector can be specified to receive an answer. Supplying it to other developers means packing it into a "framework". I'm not sure if you can include resources.

Kris Van Bael
  • 2,842
  • 1
  • 18
  • 19
1

There isn't really any equivalent. The closest you can come is having the second application call UIApplication's openURL with a custom scheme that is listened to by your app, and then when your app is done it would do the same with a custom scheme that is listened to by the calling app.

In practice, the iOS app would usually include the entire activity-equivalent as some sort of library, which at the high level would take the form of a UIViewController subclass that is presented modally and then calls a delegate method or completion selector of some sort on completion.

Anomie
  • 92,546
  • 13
  • 126
  • 145
  • I looked into this a little and it seems easy enough. If I were to use openURL, this would launch my "app" without prompting the user with anything like "open this link in:..."? It's somewhat important that the user be unaware that the app they're using has integrated my software (that's also to say that I'd prefer they not have to install my app to provide functionality). I suppose I should have mentioned that this is my first iOS app. – Tim Aug 16 '11 at 21:16
0

iPhone development is a different design than Android development, so you may need to rethink what it is you are trying to do.

Most likely you will want to look at just including the code in each program, initially, just so you can get it testable, but that may not be the best solution.

But, without knowing more details about what you are trying to do it is hard to give some suggestions as to better solutions.

For example, you may find LocalNotifications as one solution (http://useyourloaf.com/blog/2010/7/31/adding-local-notifications-with-ios-4.html), but again, it depends on what your needs are.

I found that using local notifications to call a REST service, then to process it and decide if I need to inform the user was helpful, as a replacement for how I used Intents in the Android application.

James Black
  • 41,583
  • 10
  • 86
  • 166
  • I probably wasn't specific enough in my description of my problem. To be more exact, I'm working on a piece of code that you could think of as a special type of barcode scanner. There's no use in scanning these barcodes as a consumer but existing developers can integrate this technology into their apps to provide the app with the information the user wants to provide them with. However, the UI is more involved than simply analyzing an image taken from the camera (the accelerometer comes into play all along the way). I was considering subclassing UIViewController but I feel this might be naive. – Tim Aug 16 '11 at 21:27
  • cont'd: I'd like to allow developers to very easily integrate this technology/UI into their existing apps without them having to throw large pieces of code around and/or mess with their nib files (or at least minimizing these actions). Thanks for your response. – Tim Aug 16 '11 at 21:29
  • Similar functionality is definitely possible - take a look at the TextExpander app for something similar. That said, I don't know how they implemented their functionality. – Tad Donaghe Aug 16 '11 at 22:02
  • @Terry Donaghe - It appears you just include the library, according to this: http://www.freshblocks.com/tutorials/how-to-add-textexpander-touch-sdk-to-iphone-apps/ – James Black Aug 17 '11 at 00:32