iOS call extension from my app - ios

Can I call an app extension (provided from another app) from my app.
Sample Scenario:
I have a photo asset in my app which need to be edited (crop, scale, filter...).
Now I wan't to call an app extension from my app, which supports image editing. The extension starts, the user edit the photo and I get the extension callback with the new image (data or path or something else).
I search around and only the scenarios I found is where someone creates an extension (many tutorials & apple documentations) which can be used in the photos app for example.
Or is it not possible to do that?
Thanks.

I dont think so Inter process communication is not possible in iOS each app is sandboxed

Related

Pass text from iOS label to WatchOS label - swift-

I've a problem, with my app.. I try to follow some guide like Passing data to Apple Watch app , but I'm not sure it will fit for my case.
I've some label with text on my iOS app, then I want to show this text on my watchOS app label, and I don't know which is the best way to pass this text and keep it synchronized with the iOS app..
Thanks a lot for your help!
For watchOS1, Since Watch App is included as an extension in your Host App. So, you can use App Group to share data between your Host App and your App Extension.
Refer to https://stackoverflow.com/a/44654185/5716829 for more on using App Groups.
Since watchOS2, you don't have any built in function for communicating between the iOS and watchOS app than the WatchConnectivity framework.
From the information provided in your question, the updateApplicationContext(_:) function seems to be the best solution for your problem. You can send a dictionary of data with this function and the system tries to make sure that the data is received by the time your app is displayed to the user. If the function is called several times before the app would be visible to the user (run in the foreground), the system overwrites the previous data, so the Watch app only receives the most recent data to display.
The right method for this is WCSession.updateApplicationContext(_ applicationContext: [String : Any]) https://developer.apple.com/documentation/watchconnectivity/wcsession/1615621-updateapplicationcontext "Sends a dictionary of values that a paired and active device can use to synchronize its state."

Saving files from an iOS app extension to the containing app

I'm working on adding the ability to use the share button to allow users to save files for use with my main application. Multiple file types (image, video, audio, pdf, etc) need to be supported.
A general use case would be:
The user takes a picture with the standard Camera app or audio recording using the Voice Memos app.
User clicks the Share button and selects my extension from the share list.
Dialog opens up giving the user to opportunity to give a description for the file.
File is saved to where my main app (the containing app) can later access and process it.
I've been able to get to the point where I am prompted to share the file, but I have not been able to find a location to successfully save to that my main app can later read from. Is this even possible? Is there a better way to handle this scenario?
I am currently doing this using Xamarin so debugging is not supported (and logging is minimal). If someone has an answer in Objective C, that would at least help point me in the right direction.
There are a few things that you need to do.
First, your app and your app extension should belong to the same app group:
https://developer.apple.com/library/prerelease/ios/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html#//apple_ref/doc/uid/TP40011195-CH4-SW19
Then you can access the shared storage with something like this:
var groupUrl = NSFileManager.DefaultManager.GetContainerUrl ("stackoverflow.com.mygroup")
Now you can access files in the directory pointed by groupUrl.
Xamarin's guide to creating Share extensions for iOS: http://developer.xamarin.com/guides/ios/platform_features/introduction_to_extensions/

Need help on Action Extensions iOS8

I need help on Action Extension, extension feature in iOS8. I am able to create a Action Extension target in my application and is able to see the extension in different Apps say Notes, Photos. Now, i am not able to call the appdelegate and other classes objects in the extension class.
So, how can i import Photos/notes and store it in my application?
You can't use the app delegate because it does not exist in an app extension. Extensions do not run as part of your app, they run independently of it. Moreover, [UIApplication sharedApplication] is specifically not available in app extensions, so the concept of an app delegate is not meaningful to app extensions.
As for how you can import photos and/or notes, that really depends on how your app works. Action extensions can receive data from the host app (Notes or Photos, as you mention) but how you add it to your app depends on your app's design. You get the data via NSExtensionItems, and process it however you need to process it.
Check this out. This might help you.
Appcoda Extension Tutorial
From WWDC 14 Sample Codes.
ImageInverter: Creating Action Extensions
Demonstrates how to use an Action extension with a view controller.

Access code and data in hosting app using today extension

I'm wondering if it's at all possible to access features in the main app using a today extension in iOS 8. For example, can a media player send commands from its extension to the main app without opening the app (I know there is a framework for this but it's just an example)? The only solution I can see is using URIs but the problem is that it will open the app which isn't the behavior I'm looking for.
So for a complete example using the media player:
There is an extension in the today screen that allows you to play/pause using a button.
The user presses the button and the app plays/pauses in the background without leaving the notification center.
Any way to achieve this behavior?
Code can be shared using an embedded framework, however there are some backwards compatibility issues.
Data can be shared using shared user defaults.
Both are explained in the apple docs.

What is the equivilent to a ContentObserver in iOS?

I use a ContentObserver in my android application to receive a notification whenever a photo is taken. Obviously iOS doesn't use the intent system, so is there an equivalent or alternative way to do this? I would prefer not to write a full camera application if possible.
This is not quite possible. Even the latest Google+ application on iOS, with its Instant Upload feature does not get notified when photos are taken, it simply checks the asset library while the application is running, and then as long as possible while running in the background before getting timed out by the OS.
The following is from the Google+ help on the matter:
Note: Photos and videos will upload while the Google+ application is
open and for a brief period of time afterwards.
HTH
You cannot run in the background and get notified when a picture is taken and saved to the Camera Roll by another app on iOS.
That said, you don't really need to write a whole camera app to be able to let the user take pictures from within your app, or to access Camera Roll from within your running app.
Take a look at UIImagePickerController. It is really easy to let the user select or take a photo on iOS.
There is no equivalent to ContentObserver in iOS.

Resources