iOS Share extension close action - ios

I've encountered some strange behavior of the share extension - when sharing a text, perform small drag action and let it bounce back up - it closes(not doing so with images). I've tried it with plenty of other apps - Twitter, slack - same there. Then I've tried it with the system mail application and noticed that it asks to save the draft. So apparently, there is a way to intercept this action somehow. Any ideas on how to do that? (existing completerequest or cancelrequest are not called in the code).
Also I've tried to avoid this by presenting the extension in a fullscreen mode, using
NSExtensionActionWantsFullScreenPresentation(I know that it is intended to work with action extensions, but I found that it worked for someone with sharing extension).
But it doesn't work for the sharing extensions anymore. And once again, we can see applications that run their share extensions in a fullscreen.
UPD:
isModalInPresentation = true helped to avoid dismissal by drag.
But still nothing regarding showing the extension in a fullscreen mode.

Related

For iOS, is it possible to have a Toast message that can display on top of system app Settings?

I have a button in my app that brings up the system app settings UI. Instructions are given around the button.
I want to provide further instructions to the user via a toast message after the settings page shows up so they know exactly what to do. It's not a super intuitive setting, related to notification style, and such instructions would be a lot clearer when the user is actually on the settings page.
In Android, this is easily done via toast.makeText().show(). The resulting toast would have no problem going on top of the system settings UI.
In iOS though, I've looked up several guides, mostly using the UIView animation. The problem is, the resulting toast window seems to only work inside the app itself. It cannot go on top of the system settings UI.
Is what I want to achieve technically possible in iOS?
No. You are sandboxed; Settings is a different app and you cannot impose anything on to its interface.

Tabbed iOS WebKit Browser with Swift

In short I am trying to build some typical browser functionalities in a Swift iOS app with WKWebViews (WebKit). I already have a functioning browser based on a WKWebView, which already has a menu bar with a URL input, navigation buttons, a share button, page title etc.
What I am struggling with is creating tabs for the browser. At first this seemed trivial as surely WKWebViews would support this in some way. Well, as far as I can tell they do not (looked at and tried multiple tutorials incl. hackingwithswift, Ray Wenderlich etc. + I checked Apple's documentation + stackoverflow)
This is what I have come up with so far:
1) Creating a new tab/opening a new URL should create a new UIView + WKWebView programmatically (I'll have to make a subclass out of my current browser view)
=> this should create a separate thread for each WKWebView/tab according to Apple's documentation
2) I need something like a Collection View (or Stack Views etc.) to store screenshot images of the already open tabs as a preview page of all tabs. The cells should be linked via a delegate to the corresponding WkWebView and they should have a close button to close (= delete) the tabs.
Am I overthinking this? If I go down this path I have to find a way to wire up (and subsequently delete) multiple delegates and views to the Collection View dynamically and I have to store & delete screenshots every time the user interacts with the tabs. It seems VERY messy. But given that Chrome on iOS is based on WebKit as of late, it's obviously doable.
How would you tackle this problem?
PS I didn't include a mockup because you all know how the tabs in Chrome, Safari etc. on iOS look like.
EDIT:
I am just looking for a clean and sensible way to add/remove and show the multiple WKWebViews, which are created by opening new tabs - just like in Chrome for iOS or Safari etc.
Ok, I have solved this today :) I will have a main UIView and then multiple WKWebViews, which can be "zoomed in" in order to enter full screen mode. No need for screenshots etc.

iOS 8 Interactive notifications not showing buttons by default

I'm working with the new interactive notifications in iOS 8; it fails to get the action buttons (in "banner mode") to show up by default. As it is now I have to slide down on top of the notification to see them.
Is this the default behavior, or is my code rotten?
For the images below I am using XCode 6.1.1 + iOS 8.1 (Simulator)
What I get:
What I want:
This is the default behaviour and no problem with your code.
For more details refer to the below tutorial, result is same as yours.
http://www.thinkandbuild.it/interactive-notifications-with-notification-actions/
Its a default behaviour. Don't worry about this. Apple says:
When a notification is delivered, the system displays a button for each custom action associated with the notification. Tapping a button launches your app (either in the foreground or background) and gives you a chance to perform the indicated action. You use this class to specify the text that is displayed in the button and the information your app needs to perform the corresponding action.
The options are not default behaviour. That can be done via - UIUserNotificationCategory
Refer this WWDC video - https://developer.apple.com/videos/wwdc/2014/?include=713
It's pretty straight forward and easy to implement. Let me know if you face any issues.
Everything is behaving normally. All that needs to be done is to drag down the bottom horizontal bar in the banner and the action buttons would be visible in the banner.
PS - As of iOS8. Once iOS9 comes in in a few more days, no guarantees if this is how it will still be.

iOS Share Extension Doesn't Terminate

I've created an iOS share extension with a custom UI (not using SLComposeServiceViewController) and everything works great.
Once the extension is invoked, it takes a shared URL or text and sends it. That's all it does and it works well.
The custom UI is simple. One image view that shows a graphic indicating that it is sending and then that changes to say "Sent" once done. Then this fades out.
What is going wrong is after this is done, the extension seems to disappear, but I can't control the host application anymore. It's as if an invisible window or view is on top of everything. (For example, an image rotator in Safari still rotates, but I can't scroll or tap links or buttons, etc.)
I'm calling [self.extensionContext completeRequestReturningItems:nil completionHandler:nil]; once the share is done, and as I understand it, that should dismiss my UI. I've also tried [self.view removeFromSuperview] without any luck.
Happens on Simulator and Device. Is there something I'm missing?
Edit: This is what the view hierarchy of a simple app I built to test sharing looks like in Reveal before and after sharing. The app has two buttons: share text and share url, each of which bring up a standard share sheet.
Before
http://joshh.is/1utYnKS
After
http://joshh.is/1rdVo34
Ok, I don't know why it took me 10 hours to realize that I was not including a call to super inside of my beginRequestWithExtensionContext: method.
I don't know what other problems that caused, but it certainly caused my problem above.

Are there any other iOS system sounds available other than 'tock'?

I have implemented an alternative keyboard on my first iPhone app. I would like to play a sound when a button is pressed. The default click sound when the standard keyboard is pressed would be fine, but I don't know how to get that sound.
In this answer I found how to play a 'tock' sound:
Playing system sound without importing your own
I got this to work easily enough but it is a very loud sound. I've searched Stack Overflow and the Xcode help for available iOS system sounds other than 'tock' and I can't find them.
Are there other built-in sounds, maybe even the default keyboard sound, that I can use?
Prior to, and since posting this question almost 2 weeks ago I have searched high and low for a method to make the keyboard click sound work in my app. I have attempted to implement and understand Apple's documentation on custom input views. I butchered my app in many ways attempting to make it work and created several test projects. I tried to interpret how to do this from various other sources on the web. All to no avail. I have finished my app all but for this last function.
I finally hit on a simple answer towards the end of this IPhone Dev SDK form question/post. The ultimate answer is easy and can be done in a few seconds with these easy steps.
Link the 'AudioToolbox.framework' to your project (Click on your project's Target, select 'Build Phases' and under the 'Link Binary with Libraries' item click the + button and add the framework.
Add the following to the header file of the class where you want to implement the click:
#import <AudioToolbox/AudioToolbox.h>
Add the following line of code in the implementation file of your class wherever you want the keyboard click sound to appear:
AudioServicesPlaySystemSound(0x450);
THAT'S IT! AND IT WORKED!!! HALLELUJAH!
According to Paul in the other forum this has the following downside:
"keyboard keys won't be affected by the iOS user preference for keyboard sound on/off."
But when I turn the volume up or down on my iPhone or if I mute the iPhone, the keyboard click sounds do go up and down or are muted as would be expected. Given that I found it impossible to implement keyboard clicks "UIInputViewAudioFeedback" as documented, I'm happy to have anything work.
P.S. If anyone has a link to an actual project that I can download, build and run on my iPhone to see EXACTLY how to properly implement: "UIInputViewAudioFeedback" I'd be happy to give it a look. But so far I've found none, nor any step-by-step newbie style instructions on how to make it work.
[Sept 30, 2012 UPDATE:] I'm happy to say that my app was accepted into the app store using this method. Here it is: https://itunes.apple.com/app/fine-tip-tip-calculator/id563429225
...Dale
Try UIDevice's playInputClick:
[[UIDevice currentDevice] playInputClick];
From the documentation:
Use this method to play the standard system keyboard click in response to a user tapping in a custom input or keyboard accessory view. A click plays only if the user has enabled keyboard clicks in Settings > Sounds, and only if the input view is itself enabled and visible.
Make sure you adopt the UIInputViewAudioFeedback protocol in your input view class, and implement the enableInputClicksWhenVisible delegate method to return YES, as per the documentation.
EDIT - For implementation of delegate methods, check out Apple's documentation on custom input views.

Resources