UIActivityViewController display is scrolled in last iOS11 GM on iPhone7Plus - scroll

Since the last release of iOS11 (GM version), the activity view is displayed scrolled to the top, with a spring resistance preventing the user to 'unscroll' it.
Previous version of iOS 11 (beta version) never suffered from this, nor iOS 10.
Also, one can see a blank margin at the bottom plus the fact that the preview image is not fetched/displayed right in the Website preview.
Here is the code. Any idea?
let textToShare = "\(message) (\(share))"
let objectsToShare : [Any] = [textToShare, url]
let activityViewController = UIActivityViewController(activityItems: objectsToShare as [AnyObject], applicationActivities: nil)
// New Excluded Activities Code
activityViewController.excludedActivityTypes = [.airDrop, .addToReadingList]
activityViewController.completionWithItemsHandler = {
(activityType: UIActivityType?, completed: Bool, returnedItems: [Any]?, error: Error? ) -> Void in
_completed(completed)
}

Ok. It’s only Twitter app itself that had to be updated for iOS11 (as in iOS11, there is no longer centralized system, sharing is handled by apps such as Facebook or Twitter themselves).

Related

How to preserve split view divider configuration in Mac Catalyst app?

Mac apps that have a sidebar (Mail, Finder, etc) allow you to resize its width, and that width is preserved across app launches. You enable this behavior in an AppKit app by assigning autosaveName on your NSSplitView. How do you do this in a Mac Catalyst app using UISplitViewController?
By default, my Catalyst app's sidebar is pretty wide, so every time the user opens it they have to resize it.
I reached out to a friend who was able to achieve this in their app. They said you can manually save the current width to UserDefaults and upon creating the split view controller set its preferredPrimaryColumnWidth to the last saved width. Nice!
In my UISplitViewController subclass I added:
init() {
let lastWidth = UserDefaults.standard.integer(forKey: "SidebarWidth")
let initialWidth = lastWidth > 0 ? CGFloat(lastWidth) : 220
preferredPrimaryColumnWidth = initialWidth
//...
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
UserDefaults.standard.setValue(Int(primaryColumnWidth), forKey: "SidebarWidth")
}

Local notifications not showing in notification center (.provisional) / iOS 15.2.1

Has anyone experienced problems with [.provisional] notifications on iOS 15? Can't get anything to show up in Notification Center in 'Quiet Delivery' mode. I'm clueless..
These are relevant extracts:
UNUserNotificationCenter.current().requestAuthorization([.provisional, .alert])
// -> granted: true
let content = UNMutableNotificationContent()
content.title = "Test"
content.body = "Test"
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 1, repeats: false)
let request = UNNotificationRequest(identifier: "some_id...", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)}
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification, ...)
// This is called -> returning [.banner] (so it should show in foreground, not that it matters since it's provisional...)
BUT ... notifications center is empty.
The same code works fine using non-provisional mode (user granting explicit consent to notifications).
Is there something obvious I might be missing here?
--
UPDATE: Ok, not much of an answer, but clear observation:
Putting app into background -> above code does deliver notification into notification center.
This means that .provisional mode completely ignores 'willPresent notification:' return value [which allows presentation in foreground] AND does not deliver notification into notification center if app is in foreground.
I guess I can live with that and it kind of makes sense... (?).

How to share a link on Facebook Messenger from other apps?

From Facebook Developer Documentation, I see that I can share image, animated image, even audio clips from other app to Facebook Messenger. But I can see no way to share a link. Neither does when I try to look what kind of share does the FBSDKMessengerShare offer.
How can I share a link using Facebook Messenger?
Seems that it can't be done with FBSDKMessengerShare, but with FBSDKShareKit it's possible. (I'm using Xcode 8.3, Swift 3.1, Cocoapods with FacebookShare 0.2.0)
More info available at
https://developers.facebook.com/docs/sharing/ios
There are two methods:
Using FBSDKMessageDialog:
"The Message Dialog switches to the native Messenger for iOS app, then returns control to your app after a post is published."
#IBAction func messengerButtonAction(_ sender: UIButton) {
let linkContent = FBSDKShareLinkContent()
linkContent.contentURL = URL(string: "https://itunes.apple.com/in/app/someValidAppURL...")
let dialog = FBSDKMessageDialog()
dialog.shareContent = linkContent
dialog.shouldFailOnDataError = true
if dialog.canShow() {
dialog.show()
}
}
Using FBSDKSendButton: "The Send button lets people privately send photos, videos and links to their friends and contacts using the Facebook Messenger. The Send button will call a Message dialog."
This creates a share button that is displayed in a specified view. The button will be automatically disabled if the Messenger app is not installed on the device.
override func viewDidLoad() {
let linkContent = FBSDKShareLinkContent()
linkContent.contentURL = URL(string: "https://itunes.apple.com/in/app/someValidAppURL...")
let button = FBSDKSendButton()
button.shareContent = linkContent
if button.isEnabled {
self.view.addSubview(button)
}
}

Local movie player is black and stuck as loading (Swift)

I am trying to play a local movie in my app, but when I call my method to start playing the movie, the player appears but is always black and I have a loading message. Can someone help me understand this?
func startPlayingVideo() {
let fileURL = NSBundle.mainBundle().URLForResource("Sample", withExtension: "m4v")
moviePlayer = MPMoviePlayerController(contentURL: fileURL)
moviePlayer.prepareToPlay()
/* Scale the movie player to fit the aspect ratio */
moviePlayer.scalingMode = .AspectFit
view.addSubview(moviePlayer.view)
moviePlayer.setFullscreen(true, animated: false)
/* Let's start playing the video in full screen mode */
moviePlayer.play()
}
#IBAction func playVideo(sender: AnyObject) {
//play movie
startPlayingVideo()
}
I'm not as experienced with coding with videos. Thanks in advance to the community.
May be your fileURL become nil at runtime so try this following
In the Project Navigator select your project root > your Target > Build Phases > Copy Bundle Resources. If your video is not listed in this list you should add it using the plus button
may be this will work.

WKWebView Cache manifest not working IOS8

Cache manifest works fine and events fired in safari in IOS 8. Not working at all in WKWebView anyone else solve this issue?
import UIKit
import WebKit
class ViewController: UIViewController {
#IBOutlet var containterView : UIView! = nil
var webView : WKWebView?
override func loadView(){
super.loadView()
self.webView = WKWebView()
self.view = self.webView!
}
override func viewDidLoad() {
super.viewDidLoad()
var url = NSURL(string:"http://html5demos.com/offlineapp")
var req = NSURLRequest(URL:url)
self.webView!.loadRequest(req)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
The application cache comes back as supported if I were to use html5test.com
EDIT:
window.applicationCache does not return undefined either when loaded from WKWebView
console.log("Initializing Page");
if (window.applicationCache == undefined){
console.log("Application cache not suported!");
updateSplash();
}
console.log(window.applicationCache); returns: DOMApplicationCache
EDIT 2:
if (typeof window.applicationCache.update === 'function'){
console.log("Application has method update");
console.log(window.applicationCache.update); //shows swapCache() and update() methods
window.applicationCache.update();
}
window.applicationCAche.update() throws Error: InvalidStateError: DOM Exception 11: An attempt was made to use an object that is not, or is no longer, usable.
Just for the record, this question appears to have been asked on and linked from the Apple Developer Forums. The official response from Apple is that the HTML5 Application Cache functionality is not available in WKWebView:
The offline application cache is not enabled in WKWebView. Feel free to request that it be made available via https://bugreport.apple.com.
I think you are trying to solve the same problem as I do. This is what I do.
Save the start page of your web app into one HTML file(index.html), embedding everything (CSS, JS, images as base 64, icon fonts). And add that file into your Xcode project.
Start the app by reading the content of the HTML file and load it in your WKWebView. You can set the base as the same url you are supposed to start with. This way, it'll be as if the web app is opened on your web site.
The benefit is that your app will always start even when the user's network isn't good. Here's the SWIFT code that I use, courtesy of Matt Neuberg (https://books.google.com/books?id=wLaVBQAAQBAJ&pg=PT669&lpg=PT669&dq=addConstraints+wkwebview&source=bl&ots=7trE7MR1zR&sig=VT6GDBGbDw9dh89wDb5Uajd4gUY&hl=en&sa=X&ei=cyyeVNH4MM3ToATukoDgAQ&ved=0CDkQ6AEwBA#v=onepage&q=addConstraints%20wkwebview&f=false). If you want the full source code, please let me know and I'll post it on Github.
let templatepath = NSBundle.mainBundle().pathForResource("index", ofType: "html")!
let base = NSURL(string:"http://m.ftchinese.com/iphone-2014.html#iOSShare")
var s = NSString(contentsOfFile:templatepath, encoding:NSUTF8StringEncoding, error:nil)!
self.webView!.loadHTMLString(s, baseURL:base)

Resources