Giter Club home page Giter Club logo

Comments (9)

parkerdan avatar parkerdan commented on August 20, 2024 6

@benjie, thanks anyways.

FYI, I have this working and can put together a tutorial if anyone gets to this message and needs clarification. I have only developed iOS so far, but the goal is both platforms

from react-native-share-extension.

pkantsedalov avatar pkantsedalov commented on August 20, 2024 2

@parkerdan
Please share the tutorial with me in any way preferable for you.

from react-native-share-extension.

benjie avatar benjie commented on August 20, 2024 1

I just used https://github.com/oblador/react-native-keychain to share credentials between the share extension and the main app; there's two important things to note:

  1. react-native-keychain defaults to a "service" of the identifier of the app, which differs between the app and the extension. Thus you must explicitly set them to be the same via the service option. (Took me longer than I'd like to admit to figure this out.)
  2. you should set the Keychain Access Groups in both the app and the extension to be an array with just one value which should be the exact same string, which should be prefixed with $(AppIdentifierPrefix).

from react-native-share-extension.

jvandenaardweg avatar jvandenaardweg commented on August 20, 2024 1

Just found this issue here when I was struggling with the same. I got it working by the steps described below. Hope this helps others!

Bundle Identifier used in this example: com.example.appname (use the one from your Main App)

  1. Make sure you have a App Group set up in your main App and Extension. They need to have the same name, for example: group.appname

  2. Make sure your main App and Extension have "Keychain Sharing" enabled. The Keychain Group need to be the same, for example: keychainGroup.

  3. Then, use the method's like this:

const credentials = await Keychain.getGenericPassword({ accessGroup: 'group.appname', service: 'com.example.appname' });

await Keychain.setGenericPassword('username', 'password', { accessGroup: 'group.appname',  service: 'com.example.appname' });

The service (Bundle Identifier) option seem to be required in this use case with an extension.

Thanks @benjie for pointing that out.

from react-native-share-extension.

alinz avatar alinz commented on August 20, 2024

@shishircc, No, Share Extension have no access to main app, even thought they are bundle together. I have created a new project called react-native-swiss-knife which created a pipe between share and main app. Take a look at the Bucket api inside that project. You don't have to use it but this is what I'm doing for sharing data between them.

from react-native-share-extension.

shishircc avatar shishircc commented on August 20, 2024

Thanks !

from react-native-share-extension.

npomfret avatar npomfret commented on August 20, 2024

You can use a shared filesystem. With iOS app groups can share a directory where you could store your database. I've recently had a PR accepted to react-antive-fetch-blob that adds a function which will return the name of the shared directory for a given app group.

from react-native-share-extension.

parkerdan avatar parkerdan commented on August 20, 2024

@benjie, can you please explain more on how you got this to work? I am trying to share data from the main app the the share extension with react-native-keychain and I keep getting false when calling the getGenericPassword on the share extension...

from react-native-share-extension.

benjie avatar benjie commented on August 20, 2024

Sorry, that’s all I remember. I do remember expecting some things to be the same but they turned out to differ and that was the issue ultimately (though I don’t remember which thing that was); I suggest you look at each of the values I have mentioned in the compiled app and see where the disparity lies. Good luck!

from react-native-share-extension.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.