App Store link "rate the application" in SwiftUI - swift

I just updated my "Rate the application" button that I'm using in all my apps. Actually, I would prefer to get not only a rating but a rating + a comment.
So I replaced this:
if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
SKStoreReviewController.requestReview(in: scene)
}
By this:
let url = URL(string: "https://apps.apple.com/app/(AppName)/(AppID)?action=write-review")!
UIApplication.shared.open(url)
And it's working perfectly fine!
But now, I'm wondering what should I do about the "encryption request" from Apple? Some people say there's no need for a "https" call to the App Store but Apple says a bit different: https://help.apple.com/app-store-connect/#/dev88f5c7bf9
What you guys are doing? Did you asked a document from the BIS or not?

Related

How do I use background fetch in iOS 13 to update pdfs?

I watched many videos and read many articles about the new background fetch in iOS 13, but I am still in the dark. I am making a dining app. Amongst other things I am presenting the menu for "today", which is changing every day. So far I use the PDFKit to show an example menu of a restaurant and have the menu for "today" and "tomorrow" downloaded into my project folder, but I want to use background fetch to get the menu updated every day. So far I only understood that I will have to check the boxes for "background fetch" and "background processing", where the refresh task is used to update content and the processing is used to clean up.
I am also wondering if I need my own website where I upload the pdf to retrieve the url from there. In the end I have to update an image and some labels as well, but I hope that I'll be able to do that on my own once I understood the principles.
I show you my code and screenshot of my view controller to give you a better understanding of my app so far.
let today = "AmericanDinerMenu" // PDF 1 with menu for today
let tomorrow = "ConniesDinerMenu" // PDF 2 with menu for tomorrow
func activePDF(PDF: String) {
if let path = Bundle.main.path(forResource: PDF, ofType: "pdf") {
let url = URL(fileURLWithPath: path)
if let pdfDocument = PDFDocument(url: url) {
pdfView.displayMode = .singlePageContinuous
pdfView.autoScales = true
pdfView.document = pdfDocument
}
}
}
I hope you can help me. Thank you!

turn-by-turn navigation with google maps url scheme swift

How can I enable turn-by-turn navigation with google maps urlscheme?. I used below url in swift
comgooglemaps://?saddr=%f,%f&daddr=%f,%f&directionsmode=driving
but it only creates a route, the start navigation button is not present when the google maps app is activated.
am i missing something?
let kGoogleMapsSchema = "comgooglemaps://"
let path = "\(kGoogleMapsSchema)?saddr=%f,%f&daddr=%f,%f&directionsmode=driving"
guard let finalURLString = String(format: path, currentUserCoordinates!.latitude, currentUserCoordinates!.longitude, destinationCoordinates!.latitude, destinationCoordinates!.longitude, currentUserCoordinates!.latitude, currentUserCoordinates!.longitude).addingPercentEncoding(
withAllowedCharacters: .urlQueryAllowed) else {
return
}
guard let url = URL(string: finalURLString) else {
return
}
if #available(iOS 10, *) {
UIApplication.shared.open(url)
} else {
UIApplication.shared.openURL(url)
}
am i missing something?
I found the answer as only preview button was available instead of start navigation. Because I was giving start coordinates not of my current location. So in case it is my current coordinates it will work.
Google Maps, No Option for Starting the Navigation, Only Preview is there

How to create apple watchOS5 complication?

I've never worked in WatchOS5 and want to develop a horizontal complication (Modular large) for AppleWatch, like "Heart Rate". The idea is that I would display heart rate data in a different way. Right now I want to deploy the complication on development watch.
I have created a new project with a checkbox for "complication" added. I see that this added a complications controller with timeline configuration placeholders.
There is also an storyboard with a bunch of empty screens. I'm not sure as to how much effort I need to put into an apple watch app before I can deploy it. I see this Apple doc, but it does not describe how to layout my complication. Some section seem to have missing links.
Can I provide one style of complication only (large horizontal - modular large)
Do I need to provide any iPhone app content beyond managing the
complication logic, or can I get away without having a view controller?
Do I control the appearance of my complication by adding something to the assets folder (it has a bunch of graphic slots)?
Sorry for a complete beginner project, I have not seen a project focusing specifically on the horizontal complication for watch OS 5
You should be able to deploy it immediately, though it won't do anything. Have a look at the wwdc video explaining how to create a complication: video
You can't layout the complication yourself, you can chose from a set of templates that you fill with data. The screens you are seeing are for your watch app, not the complication.
You don't have to support all complication styles.
The complication logic is part of your WatchKit Extension, so technically you don't need anything in the iOS companion app, I'm not sure how much functionality you have to provide to get past the app review though.
Adding your graphics to the asset catalog won't do anything, you have to reference them when configuring the templates.
Here's an example by Apple of how to communicate with the apple watch app. You need to painstakingly read the readme about 25 times to get all the app group identifiers changed in that project.
Your main phone app assets are not visible to the watch app
Your watch storyboard assets go in WatchKit target
Your programmatically accessed assets go into the watch extension target
Original answers:
Can I provide one style of complication only (large horizontal -
modular large) - YES
Do I need to provide any iPhone app content beyond
managing the complication logic, or can I get away without having a
view controller? YES - watch apps have computation limits imposed on them
Do I control the appearance of my complication by
adding something to the assets folder (it has a bunch of graphic
slots)? See below - it's both assets folder and placeholders
Modify the example above to create a placeholder image displayed on the watch (when you are selecting a complication while modifying the screen layout)
func getPlaceholderTemplate(for complication: CLKComplication, withHandler handler: #escaping (CLKComplicationTemplate?) -> Void) {
// Pass the template to ClockKit.
if complication.family == .graphicRectangular {
// Display a random number string on the body.
let template = CLKComplicationTemplateGraphicRectangularLargeImage()
template.textProvider = CLKSimpleTextProvider(text: "---")
let image = UIImage(named: "imageFromWatchExtensionAssets") ?? UIImage()
template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
// Pass the entry to ClockKit.
handler(template)
}else {
handler(nil);
return
}
}
sending small packets to the watch (will not send images!)
func updateHeartRate(with sample: HKQuantitySample){
let context: [String: Any] = ["title": "String from phone"]
do {
try WCSession.default.updateApplicationContext(context)
} catch {
print("Failed to transmit app context")
}
}
Transferring images and files:
func uploadImage(_ image: UIImage, name: String, title: String = "") {
let data: Data? = UIImagePNGRepresentation(image)
do {
let fileManager = FileManager.default
let documentDirectory = try fileManager.url(for: .cachesDirectory,
in: .userDomainMask,
appropriateFor:nil,
create:true)
let fileURL = try FileManager.fileURL("\(name).png")
if fileManager.fileExists(atPath: fileURL.path) {
try fileManager.removeItem(at: fileURL)
try data?.write(to: fileURL, options: Data.WritingOptions.atomic)
} else {
try data?.write(to: fileURL, options: Data.WritingOptions.atomic)
}
if WCSession.default.activationState != .activated {
print("session not activated")
}
fileTransfer = WCSession.default.transferFile(fileURL, metadata: ["name":name, "title": title])
}
catch {
print(error)
}
print("Completed transfer \(name)")
}

Disable the loading of Stylesheets in UIWebView and/or WKWebView

I have absolutely tried everything with this one. I've read every apple article and no where can I find how to disable the loading of CSS (Styling) in the legacy UIWebView or the new WKWebView. I don't mind what web view I use just as long as it can accomplish this.
I've tried WKPreferences() and WKWebViewConfiguration and both have no member userStyleSheetEnabled.
I've referred myself to this apple article https://developer.apple.com/documentation/webkit/webpreferences/1536396-userstylesheetenabled?
Does anyone know the answer and how to achieve this on Swift 4?
The WebView class you referenced is very old and has been deprecated. If you need to add a webview to your app, use WKWebView instead. This answer works with iOS >= 11 and macOS >= 10.13.
What you need is adding WKContentRuleList to your WKWebView's configuration. They are similar to Safari content blockers (i.e. ad-blockers) that you may already have installed on your phone:
// This should ideally be in a file but we're using string for convenience
let jsonRuleList = """
[{
"trigger": {
"url-filter": ".*",
"resource-type": ["style-sheet"]
},
"action": {
"type": "block"
}
}]
"""
// Compile the content-blocking list
WKContentRuleListStore.default().compileContentRuleList(forIdentifier: "blockStyleSheet", encodedContentRuleList: jsonRuleList) { list, error in
guard error == nil else { print(error!.localizedDescription); return }
guard let list = list else { return }
// Add the stylesheet-blocker to your webview's configuration
let configuration = WKWebViewConfiguration()
configuration.userContentController.add(list)
// Adding the webview to the view. Nothing to see here
self.webView = WKWebView(frame: self.view.bounds, configuration: configuration)
self.view.addSubview(self.webView)
// Let's try Apple's website without CSS
let request = URLRequest(url: URL(string: "https://www.apple.com")!)
self.webView.load(request)
}
Result:
References
Customized Loading in WKWebView (WWDC video)
Creating Safari Content-Blocking Rules

iOS9 FBSDKShareDialog native sharing not completes a post to facebook

I have an app written in Swift3 for iOS9 which attempts to share a custom link with image and description to facebook. The inter-app switching Plist keys are configured correctly - the user is asked for permission to open facebook, then a native facebook post is created in FB app.
The issue is that upon tapping Post, the user is returned to my app, but the FB post does not complete. I see a little black screen with a progress indicator flash, but the user is returned to my app before the progress is filled. (Same progress indicator fills up when using "automatic" share mode within the app)
How to make sure that FBSDKShareDialog completes posting a link to facebook native app before returning to my app?
let content = FBSDKShareLinkContent()
content.contentURL = URL(string: "http://customurl.com/")
content.contentTitle = "Custom Title"
content.contentDescription = "Custom description"
if let imageUrlUnwrapped = imageUrl {
content.imageURL = URL(string: imageUrlUnwrapped)
}
let dialog = FBSDKShareDialog()
dialog.fromViewController = self;
dialog.shareContent = content;
let url = URL(string: "fbauth2://")
if UIApplication.shared.canOpenURL(url!)
{
dialog.mode = FBSDKShareDialogMode.native
}
dialog.show()