Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share Extension stopped working in ios 18 #185

Open
pavelustenko opened this issue Sep 27, 2024 · 8 comments
Open

Share Extension stopped working in ios 18 #185

pavelustenko opened this issue Sep 27, 2024 · 8 comments

Comments

@pavelustenko
Copy link

After I updated to ios 18 and XCode 16 I can not get Sharing Extension work anymore. When I choose my app as share destination nothing happens anymore. Moreover, there's no log entry with any error. This behaviour is the same in debug and release modes.
Please help!

@hatn-lumin
Copy link

The error is caused by Xcode 16. Please downgrade Xcode and rebuild.

@mgvictor7
Copy link

This worked for me with Xcode 16 and iOS18

In the file ShareViewController.swift

@available(iOSApplicationExtension, unavailable) // <- Add this line
class ShareViewController: SLComposeServiceViewController {
...
// Update this function
private func redirectToHostApp(type: RedirectType) {
   guard let url = URL(string: "\(shareProtocol)://dataUrl=\(sharedKey)#\(type)") else {
      dismissWithError()
      return //be safe
   }

   UIApplication.shared.open(url, options: [:], completionHandler: completeRequest)
 }

// Add this funcion
func completeRequest(success: Bool) {
    extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
  }

I hope this helps you

@phuocnguyenncc
Copy link

@mgvictor7 On iOS, is it possible to take a screenshot and immediately share it within the app? I’m encountering an issue where I can only save the screenshot to the gallery before being able to share it. Image example below:

IMG_8216

@mgvictor7
Copy link

@phuocnguyenncc you can apply this correction that is discussed in the following link

achorein/expo-share-intent-demo#28

@HwanKim-actionpower
Copy link

This worked for me with Xcode 16 and iOS18

In the file ShareViewController.swift

@available(iOSApplicationExtension, unavailable) // <- Add this line
class ShareViewController: SLComposeServiceViewController {
...
// Update this function
private func redirectToHostApp(type: RedirectType) {
   guard let url = URL(string: "\(shareProtocol)://dataUrl=\(sharedKey)#\(type)") else {
      dismissWithError()
      return //be safe
   }

   UIApplication.shared.open(url, options: [:], completionHandler: completeRequest)
 }

// Add this funcion
func completeRequest(success: Bool) {
    extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
  }

I hope this helps you

you save my life. thank you bro. 👍

zatteo added a commit to cozy/cozy-flagship-app that referenced this issue Oct 17, 2024
zatteo added a commit to cozy/cozy-flagship-app that referenced this issue Oct 22, 2024
zatteo added a commit to cozy/cozy-flagship-app that referenced this issue Oct 22, 2024
zatteo added a commit to cozy/cozy-flagship-app that referenced this issue Oct 23, 2024
@feyzilim
Copy link

This worked for me with Xcode 16 and iOS18

In the file ShareViewController.swift

@available(iOSApplicationExtension, unavailable) // <- Add this line
class ShareViewController: SLComposeServiceViewController {
...
// Update this function
private func redirectToHostApp(type: RedirectType) {
   guard let url = URL(string: "\(shareProtocol)://dataUrl=\(sharedKey)#\(type)") else {
      dismissWithError()
      return //be safe
   }

   UIApplication.shared.open(url, options: [:], completionHandler: completeRequest)
 }

// Add this funcion
func completeRequest(success: Bool) {
    extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
  }

I hope this helps you

you saved my time

@smfunder
Copy link

smfunder commented Nov 29, 2024

@feyzilim sorry, where did you find that file ShareViewController.swift ? I only have ReceiveSharingIntent.swift from this library or am I crazy? Nevermind, I just found it in the share extension... of course!

@smfunder
Copy link

This worked for me with Xcode 16 and iOS18

In the file ShareViewController.swift

@available(iOSApplicationExtension, unavailable) // <- Add this line
class ShareViewController: SLComposeServiceViewController {
...
// Update this function
private func redirectToHostApp(type: RedirectType) {
  guard let url = URL(string: "\(shareProtocol)://dataUrl=\(sharedKey)#\(type)") else {
     dismissWithError()
     return //be safe
  }

  UIApplication.shared.open(url, options: [:], completionHandler: completeRequest)
}

// Add this funcion
func completeRequest(success: Bool) {
   extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
 }

I hope this helps you

You saved my stress!

Ldoppea pushed a commit to cozy/cozy-flagship-app that referenced this issue Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants