Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoking an action on a locked device doesn't work #9

Closed
francosolerio opened this issue Mar 21, 2017 · 5 comments
Closed

Invoking an action on a locked device doesn't work #9

francosolerio opened this issue Mar 21, 2017 · 5 comments

Comments

@francosolerio
Copy link

I tried to use CallbackURLKit on a Today Extension Widget. When one button on the widget is pressed, it should invoke an action on the main application via a url action.

try? Manager.perform(action: "playcollection", urlScheme: "bingobongo", parameters: parameters)

This works when invoking the action from the extension with the device unlocked, but if the device is locked the system doesn't ask to unlock and simply disregards the action.

The problem comes from Manager.open(url: Foundation.URL) that calls: UIApplication.shared.openURL(url)

To let the device ask for the unlock code and then invoke the action, there's a similar method on NSExtensionContext: func open(_ URL: URL, completionHandler: ((Bool) -> Void)? = nil)

The same issue is descibed here:

http://stackoverflow.com/questions/26909821/ios-8-today-widget-and-locked-device

It would be useful to inject the current NSExtensionContext in a non-default Manager object, that when extensionContext is not nil will invoke this method instead of the one from UIApplication.

@phimage
Copy link
Owner

phimage commented Mar 25, 2017

The framework cannot compile in iOS app extension due to UIApplication.sharedcode
How do you achieve to make it work with device unlocked?
(maybe you compile the framework without extension context and use it for both, app and extension)

the link you post it's not pure iOS but Xamarin

I think there is also an issue with application name, taken from main bundle

To fix the compile issue a compilation flag could be added to replace the current code by one using NSExtensionContext
like I do here
https://github.com/OAuthSwift/OAuthSwift/wiki/Work-with-application-extension
for cocoapod I will update the demo podfile as example
https://github.com/phimage/CallbackURLKit/blob/master/SampleApp/Podfile

@francosolerio
Copy link
Author

I don't use CocoaPods. I added CallbackURLKit to my project as a subproject and added CallbackURLKit.framework to both my app and my today extension's target in the section Linked Frameworks and Libraries. This way it compiles for both with no issues.

@phimage
Copy link
Owner

phimage commented Mar 25, 2017

I suppose that app extension has underneath also the UIApplication.shared attribute
(apple could call this using hidden and private API, event if it is not on purpose)

phimage pushed a commit that referenced this issue Jul 6, 2017
An NSExtensionContext must be set in Manager to open urls
@phimage
Copy link
Owner

phimage commented Jul 6, 2017

I add a compilation flag APP_EXTENSIONS
an instance of NSExecutionContext in Manager to open URLs

No tested yet

For carthage maybe the only possibility is to create a new shared scheme with a new target with specific name

@phimage
Copy link
Owner

phimage commented Mar 19, 2019

Closed for no activity

@phimage phimage closed this as completed Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants