App store link in MFMessageComposeViewController shows old image - swift

I have added the URL string for my app to the body of the MFMessageComposeViewController but when I run the app and send a message the image is an old image from the app store. How can I get it to use the current image from the app store.
fileprivate func textMessage() {
let appURL_Id = "https://apps.apple.com/us/app/simple-password-keeper/id1326895566"
let canSend = MFMessageComposeViewController.canSendText()
if canSend == true {
let messageVC = MFMessageComposeViewController()
messageVC.body = passwordString + "\n\n" + "Sent by Simple Password Keeper" + "\n\n" + appURL_Id
messageVC.messageComposeDelegate = self
self.present(messageVC, animated: true, completion: nil)
}else{
cantSendTextOrEmailAlert(alertTitle: multiUse.alertTitle, alertMessage: multiUse.messageSMS)
}
}
And it needs to be.

What is happening is that in iTunes Connect there is an old preview that was not removed. Look under the View All Sizes Media Manager.

Related

When I redirect the user from ShareExtensions to the App, the App opens but then instantly closes

As written in the subject, I would like to redirect the user to my App when he's using share extensions. For example when he tries to share a photo through my app - he opens the images, clicks on share, selects my app and then he is redirected to the app. He is in fact, but when he is, the app opens and then instantly closes. I made the solution in reference to this:
https://kitefaster.com/2016/07/13/how-to-open-ios-app-with-custom-url/
(adding all the necessary stuff in plist)
And in Share Extensions I made the following function:
func redirectToApp() {
let urlString = "myAppName://"
let url = NSURL(string: urlString)
let selectorOpenURL = sel_registerName("openURL:")
let context = NSExtensionContext()
context.open(url! as URL, completionHandler: nil)
var responder = self as UIResponder?
while (responder != nil) {
if responder?.responds(to: selectorOpenURL) == true {
responder?.perform(selectorOpenURL, with: url)
}
responder = responder!.next
}
}

Implementing "Open file with" in Swift Cocoa App

I'm working on a macOS cocoa-app in Swift where I import several different file types into the app for the user to interact with.
I'm currently trying to determine if it's possible to implement the "Open file with" feature, so that the user could open those files in a different program if they wanted to:
I've found a few different SO questions that seem tangentially related to what I'm trying to do:
Swift: How to open file with associated application?
Launch OSX Finder window with specific files selected
...but so far nothing to indicate if it's possible to implement right-click Finder/file (?) access in the way I had in mind.
Apologies if this is too vague of a question; any help / guidance appreciated!
Without going into details, it's pretty straight forward:
Get the list of all known applications that can open a specific file type (see LSCopyApplicationURLsForURL, a Core Foundation C function).
Build the menu. You can use NSWorkspace (and probably URL) to get the application icons.
Use NSWorkspace.openFile(_:withApplication:) to tell the application to open the given document.
2022, Swift 5
Get app list associated with local file:
func getAppsAssociatedWith(_ url: URL?) {
guard let url = localFileURL,
let retainedArr = LSCopyApplicationURLsForURL( url as CFURL, .all)?.takeRetainedValue(),
let listOfRelatedApps = retainedArr as? Array<URL>
else {
return []
}
return listOfRelatedApps
}
Getting thumbnail for app:
let singleAppIcon = NSWorkspace.shared
.icon(forFile: appUrl.path)
.scaledCopy(sizeOfLargerSide: 17)
Open url with app:
#available(macOS 10.15, iOS 9.0, *)
public class func openUrlWithApp(_ urls: [URL], appUrl: URL) {
NSWorkspace.shared.open(urls, withApplicationAt: appUrl, configuration: NSWorkspace.OpenConfiguration())
}
In my app I'm cashing all apps icons in dictionary.
[someFile localURL : app icon]
If I have already got icon earlier - no need to get it once more
var relatedAppsThumbnails: [URL: Image] = [:]
func updateRelatedApps() {
guard let url = currImgUrl, // file url to get icons from related apps
let retainedArr = LSCopyApplicationURLsForURL( url as CFURL, .all)?.takeRetainedValue(),
let listOfRelatedApps = retainedArr as? Array<URL>
else {
relatedApps = []
return
}
self.relatedApps = listOfRelatedApps
// add app icon in case of it wasn't added yet
for appUrl in listOfRelatedApps {
if relatedAppsThumbnails[appUrl] == nil {
let nsImg = NSWorkspace.shared.icon(forFile: appUrl.path)
.scaledCopy(sizeOfLargerSide: 17)
relatedAppsThumbnails[appUrl] = Image(nsImage: nsImg)
}
}
}
LSCopyApplicationURLsForURL is deprecated. You can use this alternative:
func getListOfExternalApps(forURL url: URL) -> [(URL, Image)] {
let listOfExternalApps = NSWorkspace.shared.urlsForApplications(toOpen: url)
let icons = listOfExternalApps.map {
let nsimage = NSWorkspace.shared.icon(forFile: $0.path())
nsimage.size = CGSize(width: .s16, height: .s16)
return Image(nsImage: nsimage)
}
return Array(zip(listOfExternalApps, icons))
}

Opening iMessage with default body containing a link

I am trying to open up the iMessage app with a default message from my app. The default message contains a link to the app in the app store. This is used as a way for users to invite people to download the app.
The user types in a number and then hits a submit button and then it opens up the iMessage app with that number and a refilled message. However, for some reason, Swift won't generate the URL. Here is what I have
let body = "Download SomeApp by clicking the link below:\n\nhttps://appsto.re/us/someapp.i"
guard let phoneUrl = URL(string: "sms:\(numberTextField.text!)&body=\(body)") else {
return
}
if UIApplication.shared.canOpenURL(phoneUrl) {
UIApplication.shared.open(phoneUrl, options: [:], completionHandler: nil)
}
Right now its not even getting past the guard statement.
All I want to do is open iMessage with a link to my app in the body.
You need to escape the content passed into the &body= parameter. You can do this with addingPercentEncoding.
For example:
let body = "Download SomeApp by clicking the link below:\n\nhttps://appsto.re/us/someapp.i"
guard let escapedBody = body.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed) else {
return
}
guard let phoneUrl = URL(string: "sms:\(numberTextField.text!)&body=\(escapedBody)") else {
return
}

Swift displayed firebase photoUrl cannot replace image by image picker

I use Firebase as the back-end of my app. When user finish authentication they will go to profile create page. It displays the user profile picture from facebook.
I use this code to display
func displayProfilePic(user: FIRUser?){
let photoURL = user?.photoURL
struct last {
static var photoURL: NSURL? = nil
}
last.photoURL = photoURL; // to prevent earlier image overwrites later one.
if let photoURL = photoURL {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), {
let data = NSData.init(contentsOfURL: photoURL)
if let data = data {
let image = UIImage.init(data: data)
dispatch_async(dispatch_get_main_queue(), {
if (photoURL == last.photoURL) {
self.profilePic.image = image
}
})
}
})
} else {
profilePic.image = UIImage.init(named: "DefaultPic")
}
However, I also let user to pick their own profile picture by camera or photo library. When user choose their Image it will display the picked Image for 1 to 2 second, and display back the facebook profile picture. That's mean, the "picked image cannot replace the facebook profile picture"
It is my code for the camera and photo library
func openGallary(){
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.SavedPhotosAlbum){
print("Pick Photo")
self.imagePicker.delegate = self
self.imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
self.imagePicker.allowsEditing = true
self.presentViewController(self.imagePicker, animated: true, completion: nil)
}
}
func openCamera(){
if(UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)){
self.imagePicker.sourceType = UIImagePickerControllerSourceType.Camera
self.imagePicker.allowsEditing = true
self.presentViewController(self.imagePicker, animated: true, completion: nil)
}else{
print("you got no camara")
}
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
self.dismissViewControllerAnimated(true, completion: { () -> Void in
})
profilePic.image = image
}
Firebase Authentication takes a photo URL, so the public location where a profile photo for the user is present. If you want to allow the user to upload a new profile photo, you will have to find a place to store the photo and then put the URL into the Firebase Authentication profile.
One place to keep such a profile picture would be Firebase Storage. See the documentation on how to upload an image from iOS and then generate a download URL that you store in the user profile.

Deep link not working for a case

Hey I am developing an app for the version iOS7 and above, where I have to share a content via mail or message. I use the following code
let textToShare = "Just click the following link to view "
let urlToShare = NSURL(string: "croding.com://crodid/crodname")
let objectsToShare = [textToShare, urlToShare]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
self.presentViewController(activityVC, animated: true, completion: nil)
I have added the croding.com in plist. Its working fine (open our app from mail exactly what I want) only if the app is installed already otherwise this thing is just a text instead of link. I need to show it as link even app is not installed.
croding.com://crodid/crodname