receive_sharing_intent icon indicating copy to clipboard operation
receive_sharing_intent copied to clipboard

I'm using version 1.4.5 on ios and it doesn't bring the url of the files.

Open Thiago97SLA opened this issue 4 years ago • 16 comments

I am implementing version 1.4.5 and I have followed different recommendations of using previous versions and it doesn't work either when bringing the url of the files. my IOS version is 14.8. when using receive_sharing_intent and when sharing a file it does not load.

Thiago97SLA avatar Nov 08 '21 18:11 Thiago97SLA

Were you able to fix this i am getting the same issue , only on IOS. Android works fine. I get the app when sharing , on select , it remains at the same screen.

arun-gautham avatar Jan 18 '22 10:01 arun-gautham

same issues facing me.

waqaryounusjatt788 avatar Jan 25 '22 13:01 waqaryounusjatt788

arun-gautham have you find some solution to bring back url?

waqaryounusjatt788 avatar Jan 25 '22 13:01 waqaryounusjatt788

Same issue with iOS 15.2.1 If anyone solve this issue then please share it here, Thank you.

kartik1225 avatar Jan 26 '22 16:01 kartik1225

I have not solved it yet , but i know the issue. Its not a plugin issue i guess.

its a problem with Userdefaults (NSUserDefaults) . The plugin actually depends on userDefaults in the SLcontrollerVIew under the suitename:"Appgroupid" which is used to save the file/text/image paths temporarily and then retrieve it once control is returned back to plugin. but unfortunately due to some reason the it is not able to get that , i guess it instantiates another instance instead of retrieving what is stored even though the save is successful and the group id's absolutely match.

The problem could also be limited to simulator ( if you have an actual device , someone please test and let me know) or the Xcode.

As of now this is where i stand. I will also look @ possibility of storing in a file and then retrieving it or any other ways.

Any ways this is not the first time i feel dev on IOS is a Neanderthal approach as versus android.

arun-gautham avatar Jan 27 '22 03:01 arun-gautham

@arun-gautham Thank you for your detailed response.

About actual device. I have tested on iOS 15.2.1 on iPhone 11 but still the issue remains. When I share something to my flutter app it opens if it’s close but I do not receive any callback from the stream listeners.

I do code in native android but as of now iOS is an alien world to me. Don’t know what could be the issue I have wasted 2 days.

kartik1225 avatar Jan 27 '22 04:01 kartik1225

I have found an alternate way for my use case ( only media and other files ). Using Sqlite is working fine instead of UseDefaults. Once I cleanup the code i will put on github , people are welcome to use and improve it further.

arun-gautham avatar Jan 27 '22 17:01 arun-gautham

@arun-gautham Hey thanks for the update! My use case falls into other files I will eagerly wait for your implementation!🙌🏻

kartik1225 avatar Jan 27 '22 17:01 kartik1225

https://github.com/arun-gautham/receive_sharing_intent

arun-gautham avatar Jan 28 '22 11:01 arun-gautham

Thanks Arun, For putting the effort and sharing your hard work with us. I will try your code soon.

kartik1225 avatar Jan 28 '22 13:01 kartik1225

@arun-gautham I have used your code

https://github.com/arun-gautham/receive_sharing_intent

and also went through the readme modifications from your fork but unfortunately, my app crashed when I share the file.

[unspecified] container_create_or_lookup_app_group_path_by_app_group_identifier: client is not entitled
receive_sharing_intent/SwiftReceiveSharingIntentPlugin.swift:138: Fatal error: Unexpectedly found nil while unwrapping an Optional value
receive_sharing_intent/SwiftReceiveSharingIntentPlugin.swift:138: Fatal error: Unexpectedly found nil while unwrapping an Optional value
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Unexpectedly found nil while unwrapping an Optional value
    frame #0: 0x00000001855c6d7c libswiftCore.dylib`_swift_runtime_on_report
libswiftCore.dylib`_swift_runtime_on_report:
->  0x1855c6d7c <+0>: ret    
libswiftCore.dylib`_swift_reportToDebugger:
    0x1855c6d80 <+0>: b      0x1855c6d7c               ; _swift_runtime_on_report
libswiftCore.dylib`_swift_shouldReportFatalErrorsToDebugger:
    0x1855c6d84 <+0>: adrp   x8, 335267
    0x1855c6d88 <+4>: ldrb   w0, [x8, #0x1e4]
Target 0: (Runner) stopped.
Lost connection to device.

Am I doing something wrong? Let me know if you need more data from my end. Thank you.

kartik1225 avatar Jan 28 '22 15:01 kartik1225

The first error seems to tell something wrong with entitlements. can you recheck the other config first

  1. Both app belong to same group.
  2. Both runner and share extension have updated .entitlement files.
  3. make sure you have added a varialbe CUSTOM_GROUP_ID in xcode. or hard code the group ids ever where.
  • *.entitlements file

--- share extn

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.security.application-groups</key>
	<array>
		<string>"your group id"</string>
	</array>
</dict>
</plist>

--- runner entitlement

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>com.apple.security.application-groups</key>
	<array>
		<string>your group id</string>
	</array>
	<key>com.apple.developer.associated-domains</key>
    <array>
        <string>applinks:example.com</string>
    </array>
</dict>
</plist>
  • plist files ----Runner info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>$(DEVELOPMENT_LANGUAGE)</string>
	<key>CFBundleDisplayName</key>
	<string>Off Cloud</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>"==>PUT YOUR BUNDLE NAME HERE<=="</string>
	<key>CFBundlePackageType</key>
	<string>APPL</string>
	<key>CFBundleShortVersionString</key>
	<string>$(FLUTTER_BUILD_NAME)</string>
	<key>CFBundleSignature</key>
	<string>????</string>
	<key>CFBundleVersion</key>
	<string>$(FLUTTER_BUILD_NUMBER)</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
	<key>UILaunchStoryboardName</key>
	<string>LaunchScreen</string>
	<key>UIMainStoryboardFile</key>
	<string>Main</string>
	<key>UISupportedInterfaceOrientations</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UISupportedInterfaceOrientations~ipad</key>
	<array>
		<string>UIInterfaceOrientationPortrait</string>
		<string>UIInterfaceOrientationPortraitUpsideDown</string>
		<string>UIInterfaceOrientationLandscapeLeft</string>
		<string>UIInterfaceOrientationLandscapeRight</string>
	</array>
	<key>UIViewControllerBasedStatusBarAppearance</key>
	<true/>
	<key>AppGroupId</key>
	<string>$(CUSTOM_GROUP_ID)</string>
	<key>CFBundleURLTypes</key>
		<array>
			<dict>
				<key>CFBundleTypeRole</key>
				<string>Editor</string>
				<key>CFBundleURLSchemes</key>
				<array>
					<string>ShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER)</string>
				</array>
			</dict>
		</array>
	<key>NSPhotoLibraryUsageDescription</key>
	<string>xxxxx app requires the Photos Permission to select and upload the photo</string>
</dict>
</plist>

--- share extn info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>AppGroupId</key>
	<string>$(CUSTOM_GROUP_ID)</string>
	<key>CFBundleDevelopmentRegion</key>
	<string>$(DEVELOPMENT_LANGUAGE)</string>
	<key>CFBundleDisplayName</key>
	<string>alternateStore</string>
	<key>CFBundleExecutable</key>
	<string>$(EXECUTABLE_NAME)</string>
	<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
	<key>CFBundleInfoDictionaryVersion</key>
	<string>6.0</string>
	<key>CFBundleName</key>
	<string>$(PRODUCT_NAME)</string>
	<key>CFBundlePackageType</key>
	<string>XPC!</string>
	<key>CFBundleShortVersionString</key>
	<string>$(FLUTTER_BUILD_NAME)</string>
	<key>CFBundleVersion</key>
	<string>$(CURRENT_PROJECT_VERSION)</string>
	<key>NSExtension</key>
	<dict>
		<key>NSExtensionAttributes</key>
		<dict>
			<key>NSExtensionActivationRule</key>
			<dict>
				<key>NSExtensionActivationSupportsFileWithMaxCount</key>
				<integer>1</integer>
				<key>NSExtensionActivationSupportsImageWithMaxCount</key>
				<integer>100</integer>
				<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
				<integer>100</integer>
				<key>NSExtensionActivationSupportsText</key>
				<true/>
				<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
				<integer>1</integer>
			</dict>
			<key>PHSupportedMediaTypes</key>
			<array>
				<string>Video</string>
				<string>Image</string>
			</array>
		</dict>
		<key>NSExtensionMainStoryboard</key>
		<string>MainInterface</string>
		<key>NSExtensionPointIdentifier</key>
		<string>com.apple.share-services</string>
	</dict>
</dict>
</plist>

arun-gautham avatar Jan 31 '22 04:01 arun-gautham

Thanks, @arun-gautham I will try the code again tognight!

kartik1225 avatar Jan 31 '22 11:01 kartik1225

Hello, again @arun-gautham I verified the above steps. And when I share something from the simulator then it works. but when I try receiving with the reading device (iPhone 11) app exits with the below error (Similar error as earlier).

Have you tested your app with the real device?

[VERBOSE-2:FlutterObservatoryPublisher.mm(143)] Could not register as server for FlutterObservatoryPublisher. Check your network settings and relaunch the application.
[connection] nw_read_request_report [C3] Receive failed with error "Software caused connection abort"
[unspecified] container_create_or_lookup_app_group_path_by_app_group_identifier: client is not entitled
receive_sharing_intent/SwiftReceiveSharingIntentPlugin.swift:138: Fatal error: Unexpectedly found nil while unwrapping an Optional value
receive_sharing_intent/SwiftReceiveSharingIntentPlugin.swift:138: Fatal error: Unexpectedly found nil while unwrapping an Optional value
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Unexpectedly found nil while unwrapping an Optional value
    frame #0: 0x00000001855c6d7c libswiftCore.dylib`_swift_runtime_on_report
libswiftCore.dylib`_swift_runtime_on_report:
->  0x1855c6d7c <+0>: ret    
libswiftCore.dylib`_swift_reportToDebugger:
    0x1855c6d80 <+0>: b      0x1855c6d7c               ; _swift_runtime_on_report
libswiftCore.dylib`_swift_shouldReportFatalErrorsToDebugger:
    0x1855c6d84 <+0>: adrp   x8, 335267
    0x1855c6d88 <+4>: ldrb   w0, [x8, #0x1e4]
Target 0: (Runner) stopped.

kartik1225 avatar Feb 02 '22 15:02 kartik1225

@arun-gautham I tried your library. Everything goes well with the images from gallery, but when I make screenshot it gives me this error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.'

SergiiMytakii avatar May 24 '22 14:05 SergiiMytakii

Let me check it once and get back

arun-gautham avatar May 25 '22 13:05 arun-gautham