8

I am trying to share my app URL with UIActivityViewController and here is my code:

let items = [URL(string: "https://itunes.apple.com/de/app/idxxxxxxxxx")!]
let ac = UIActivityViewController(activityItems: items, applicationActivities: nil)
present(ac, animated: true)

App URL is working fine on browser. But crashing on iPhone.

Here is the log I am getting in console:

ACAccountStore: [66A6F31E] Failed to save an account. account = | error = Error Domain=com.apple.accounts Code=7 "The application is not permitted to access iTunes Store accounts" UserInfo={NSLocalizedDescription=The application is not permitted to access iTunes Store accounts}

[accounts] ACAccountStore: Failed to create the local account. error = Error Domain=com.apple.accounts Code=7 "The application is not permitted to access iTunes Store accounts" UserInfo={NSLocalizedDescription=The application is not permitted to access iTunes Store accounts}

Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
  • I too am looking for the best way to open an activity sheet to share a link to my app. Using a `URL` object with a link of this format: `"https://apps.apple.com/gb/app/EXAMPLE-APP-NAME/idXXXXXXXXXX"` produces the same error message as above. – Jon Cox Jul 07 '20 at 19:18
  • Further clue, the "crash" I experience is actually the app hitting a breakpoint for `All Runtime Issues`. If I continue the program execution it does then work (or turn off breakpoints to start with), but still printing out all the errors noted in the question. – Jon Cox Jul 08 '20 at 11:47
  • 1
    It would still be interesting to note if these errors should be concerning. I absolutely don't want to ship a feature that works okay in development, but doesn't work in live production. – Jon Cox Jul 08 '20 at 11:48
  • Note also, that I've found these warnings can be entirely avoided if you use the new `LPLinkMetadata` to pre-populate the metadata being shared but still using the original link (as described here https://medium.com/better-programming/whats-new-in-sharing-for-ios-13-3216999ff942). However I found that it instead comes up with an "Unable to simultaneously satisfy constraints" error, but that appears to be an issue with `UIActivityViewController` itself. – Jon Cox Jul 08 '20 at 13:19

1 Answers1

1

I was getting the same errors, casting it to any and adding a title solved mine. Check the code for more clarification

let item: [Any]  = ["This app is my favorite",URL(string: "https://itunes.apple.com/de/app/idxxxxxxxxx")!]
let ac = UIActivityViewController(activityItems: items, applicationActivities: nil)
present(ac, animated: true)
David Buck
  • 3,752
  • 35
  • 31
  • 35
Charnpreet
  • 11
  • 3