How to open iOS app from within extension? - ios

My app is registered for URL Schemes:
But I have no idea how to open that app, since I cannot use UIApplication.sharedApplication() in extension. Is it possible at all?

Apple's documentation says:
A Today widget (and no other app extension type) can ask the system to open its containing app by calling the openURL:completionHandler: method of the NSExtensionContext class.

Related

Safari extension iOS - messaging from app to extension

With iOS 15, Apple had made it possible to create Safari extension for iOS as well.
I'm currently in the process of bringing an existing macOS Safari extension to iOS.
My problem is that there doesn't seem to be the option to send a message from the host app to the extension. It is possible to answer a request from the extension through the
beginRequest(with:) function. However, I actively need to send a message to the extension after an user action. In macOS, this can be done through the dispatchMessage(withName:toExtensionWithIdentifier:userInfo:completionHandler:) function as described here: https://developer.apple.com/documentation/safariservices/safari_web_extensions/messaging_between_the_app_and_javascript_in_a_safari_web_extension. This function is unfortunately not available for iOS.
Would greatly appreciate any ideas for solving this problem.
You can enable permission ["nativeMessaging"] in manifest file of the safari extension
Use appGroup to store data between the extension and your application.
In SafariWebExtensionHandler, you can response appGroup Data to the message called from any extension javascript file.

How to programmatically determine if my iMessage app extension is enabled from main app?

In the iOS Messages App Store users have the ability to control which extensions are 'added' and available to use from the iMessage Extension tray. If the app extension is not 'added' the user cannot use it and does not see as an option in their extension tray while typing a message.
I have a main app that includes an iMessage extension app.
My question is, if I have a main app that also contains an iMessage extension, how can I/can I programmatically determine what this preference is for my extension from within the main application?
The documentation and a look into the Messages framework doesn't mention this ability but perhaps there is way someone knows?

How to call a method in the parent iPhone app from Today Extension in Swift?

I have just created an Apple Watch extension to my iPhone App and used the following method to update my app data.
// Call the parent application which launches a method to update the app data
WatchViewController.openParentApplication([:],
reply: { (reply, error) -> Void in
self.updateGui() // update the gui when done
})
Is there anything similar for Apple Today Extensions (widgets)? It feels wrong to implement all the client-server communication again for the extension.
Or how do you suggest to update my data (stored in app group throughout iPhone app, WatchKit and Today Extension).
No need to write client-server communication code separate for container app and its extension.
Apple recommends embedded frameworks for the same. You create an embedded framework which can be used across both targets. Place code that will need to be used by both the container app and extension in the framework to avoid code repetition.
And for sharing data between container app and extension, you can use NSUserDefaults through AppGroup.
Please check Apple documentation.

Opening external app from custom keyboard ios 8

I wanted to know how I can open an external app from a custom keyboard in iOS 8?
is it by example possible to open Facebook, or post a Facebook message from a custom keyboard, if yes, how can I achieve this?
Thank you,
joe
I was trying to work with the UIApplication sharedApplication openURL: method in order to open the AppStore to link to the app so user's could rate it, Xcode kept telling me that the openURL method would not work in the extension. So I am sure you are able to refer back to the app itself but not open other app's which hopefully they will be able to change fairly soon.

How to launch an app using NSURL and -openURL:?

There are a few apps which I find very helpful and want to recommend to my users inside my app. If one such app is installed, and the user taps the button, I want to launch that app. Otherwise open the app page in the App Store app.
UIApplication provides a -canOpenURL: method which I think can be used to check if an app exists on the device. With -openURL: an app can be launched. But how do I construct an NSURL to launch an app?
The apps I want to refer to don't have any special registered URL scheme, at least not that I know of. All I know is their name and app ID.
Is that possible or must the developers of these apps update their apps to support custom URL opening schemes?
It is only possible to open the app by url in case it has known registered URL scheme (it may me your application or one of the existing iOS schemes)
Here is a list of public URL schemes. This however is just a fraction of what is out there in the market. It may however be helpful for you.

Resources