KasemJaffer / receive_sharing_intent

A Flutter plugin that enables flutter apps to receive sharing photos, text and url from other apps.
Apache License 2.0
325 stars 375 forks source link

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

Open Thiago97SLA opened 2 years ago

Thiago97SLA commented 2 years ago

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.

arun-gautham commented 2 years ago

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.

waqaryounusjatt788 commented 2 years ago

same issues facing me.

waqaryounusjatt788 commented 2 years ago

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

kartik1225 commented 2 years ago

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

arun-gautham commented 2 years ago

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.

kartik1225 commented 2 years ago

@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.

arun-gautham commented 2 years ago

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.

kartik1225 commented 2 years ago

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

arun-gautham commented 2 years ago

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

kartik1225 commented 2 years ago

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

kartik1225 commented 2 years ago

@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.

arun-gautham commented 2 years ago

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.

--- 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>

--- 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>
kartik1225 commented 2 years ago

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

kartik1225 commented 2 years ago

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.
SergiiMytakii commented 2 years ago

@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.'

arun-gautham commented 2 years ago

Let me check it once and get back