achorein / expo-share-intent

🚀 Simple share intent in an Expo Native Module
MIT License
119 stars 10 forks source link

Bug + Feature Request - Type consistency between android and iOS ShareIntent #40

Closed ChristopherGabba closed 3 months ago

ChristopherGabba commented 3 months ago

Describe the bug When sharing a photo from camera reel into app from:

Android:

{
  "files": 
    [
       {
           "fileName": "PXL_20230816_012320214.MP.jpg", 
           "path":"content://com.google.android.apps.photos.contentprovider/-1/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F1000000034/REQUIRE_ORIGINAL/NONE/image%2Fjpeg/1172492840", 
           "type": "image/jpeg" // call this field mimeType to better align with industry
       }
    ], 
     "text": null, 
     "type": null, // This should not be null and should be media ? This field should probably never be null unless the share intent is in error
     "webUrl": null
}

iOS:

{
  "files": 
      [
         { 
            "fileName": "IMG_3091.JPEG", 
            "path": "file:///private/var/mobile/Containers/Shared/AppGroup/F9D33AE9-E673-44E1-8C7C-124086E47C2F/728B1127-45FE-44B7-A981-74B1BAFD9EE7.JPEG", 
            "type": "media" // Duplicate? return the mimeType here instead of the media
        }
     ], 
     "text": null, 
    "type": "media",  // Duplicate?
    "webUrl": null
}

These should at least be the same on iOS and android. Proposal: Take one type and call it shareIntentType (or something like that) and call the other type mimeType. Getting mimeType would be awesome for iOS if possible to drive consistency.

Additionally when sharing webUrls on both platforms: Android:

{
  "files": null, 
   "text": "https://www.instagram.com/reel/C2szFomuSQS/?igsh=aDQwOXB3aG1tZDZv", // duplicating data with text field?
   "type": "text",  // android calls it text
   "webUrl": "https://www.instagram.com/reel/C2szFomuSQS/?igsh=aDQwOXB3aG1tZDZv" // duplicating data with webUrl field?
}

iOS:

{
   "files": null, 
   "text": "https://www.instagram.com/reel/C3D9GBNODYD/?igsh=MThwcDlpcDlzNHkzbg==", // duplicating data with webURL field?
   "type": "weburl",  // iOS calles it a webUrl
    "webUrl": "https://www.instagram.com/reel/C3D9GBNODYD/?igsh=MThwcDlpcDlzNHkzbg==" // duplicating data with text field?
}

Proposal to install some sort of regex function on android to determine if it's a url or not and make it the same as iOS. Additionally no need to duplicate data on the "text" and webUrl. If it's not exclusively a url, then call it text, otherwise call it a webUrl.

Just trying to drive consistency between the two packages. Right now I have several Platform.select sections in my javascript to account for these differences, but it really shouldn't have to be that way

Throwing one last feature request in there:

If the user shares a video or image file, would be so sick to get the metaData of the files like (width, height, video duration, file size, etc.). I'm using the react-native-compressor package to get some of the metadata right now but would be awesome if that was built in.

Environment Android and iOS

Expo 50 using latest version of npm install expo-share-intent

achorein commented 3 months ago

Hello 👋 Thanks for you feedback, indeed some harmonization have to be done.

at the moment intent.type it's not documented and should not be used, it's a specific value depending on ios or android native module, it can be used as a debug value. maybe i should just keep it in a debug log.

intent.file.type is indeed a mimeType on Android, but we doesn't have the mimeType on ios for now (in v1.0 type was 0 instead of media...), maybe we can do something based on file extension for this part.

concerning webUrl and text, it's more about extracting information. Text is a raw data (real data received) and webUrl a computed one via regex. it's not always duplicated. More details here https://github.com/achorein/expo-share-intent/issues/25#issuecomment-2000319286

for file meta data, you can give your feedback here : https://github.com/achorein/expo-share-intent/issues/34

achorein commented 3 months ago

@ChristopherGabba new version (1.3.0) is now consistent between android and iOS.

ChristopherGabba commented 3 months ago

@achorein You are the man, lets go, going to try it out now!

On another note, I've never contributed to open source before, I'm a hobbyist programmer who enjoys building apps and to be honest I've never really masted GIT, but have always waited for the right project to help out on.

I'd love to fork this project and make some documentation changes just to learn the ropes (adding function descriptions, etc.). Can you provide a step by step Contributing section to your docs? I tried:

  1. Creating fork
  2. Running git-clone on the fork
  3. Running git checkout -b add-function-notes
  4. Then I cd into the fork's location and I tried the command npm install and it all went to sh**.

After I fork the repo and git checkout, how can I effectively run the project on my iOS and android device, make a few changes, and then commit it back for you to review? These NPM packages don't quite act like a normal project when I run npm install. Do I need to cd into the example folder? (Sorry in advance, I'm an idiot)

achorein commented 3 months ago

all right, here we go CONTRIBUTING.md for running instructions.

You can check this doc for the PR workflow https://www.dataschool.io/how-to-contribute-on-github/ or https://docs.github.com/en/get-started/exploring-projects-on-github/contributing-to-a-project