Code Monkey home page Code Monkey logo

Comments (10)

thiagobrez avatar thiagobrez commented on June 2, 2024 3

@sanghaya actually even if you install AsyncStorage on your extension, you won't be sharing the storage between your app and your extension, because they reside in different places on the disk. There's an issue on @react-native-community/AsyncStorage discussing this, but this hasn't been implemented since I last checked. In my case, I was already using WatermelonDB so I managed to share the db across the app and extension on iOS via an App Group

from react-native-share-menu.

Gustash avatar Gustash commented on June 2, 2024 1

@thiagobrez I'm not sure for that specific workflow. Have you checked if the native portion of those libraries support App Group User Defaults?

Btw, I'm closing this issue in the meantime because I've had confirmation from someone that linking the pods manually on the Share Extension target fixes this issue.

If you have other unrelated issues please open a new issue for those.

from react-native-share-menu.

sanghaya avatar sanghaya commented on June 2, 2024 1

Hey, what I mean by linking is adding the pod to the share extension target in the Podfile

Hi @Gustash thanks in advance. When you say adding the pod to the Podfile, do you mean something like below and running pod install? Is there any other required step?


target 'ShareExtension' do
  use_react_native!

  pod 'RNShareMenu', :path => '../node_modules/react-native-share-menu'
  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-async-storage/async-storage'
  # Manually link packages here to keep your extension bundle size minimal
end

And then after running pod install, you would see something like this in your CLI. Is this correct?

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: 
  - @react-native-async-storage/async-storage (to unlink run: "react-native unlink @react-native-async-storage/async-storage")
  - react-native-share-menu (to unlink run: "react-native unlink react-native-share-menu")

from react-native-share-menu.

Gustash avatar Gustash commented on June 2, 2024

You can share all the code you want. The error you're getting is because you need to manually link the AsyncStorage package in your share module target. Autolinking is disabled for the share module in order to keep the bundle size minimal

from react-native-share-menu.

durdevic avatar durdevic commented on June 2, 2024

So I've followed these instructions https://react-native-community.github.io/async-storage/docs/link/ and linked it with ShareExtensions Build Phase and I'm currently ending with an iOS build error.

Should I do some specific linking?

Screenshot of my project
Screenshot 2020-08-23 at 22 17 38

from react-native-share-menu.

Gustash avatar Gustash commented on June 2, 2024

Hey, what I mean by linking is adding the pod to the share extension target in the Podfile

from react-native-share-menu.

CptMaumau avatar CptMaumau commented on June 2, 2024

I'm having a similar problem, followed the solution and added the packages I needed but now it says Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider>
I have tried wrapping my Share component in a Provider but still getting the error

from react-native-share-menu.

thiagobrez avatar thiagobrez commented on June 2, 2024

@CptMaumau I faced this yesterday but solved by wrapping it in a Provider indeed. Maybe your AppRegistry.registerComponent is pointing to the wrong function? Also, I only managed to register the extension by calling it from index.share.js

from react-native-share-menu.

thiagobrez avatar thiagobrez commented on June 2, 2024

Hey @Gustash, I'm trying to share my main app database (Watermelon / SQLite) with the Share Extension. I've already linked it to the extension target and can use it successfully, but another database instance is being created, as if it can't find the db file. I see that in ShareViewController.swift there are already some handling code for iOS Shared Containers, UserDefaults, etc. Can you point me in the right direction?

from react-native-share-menu.

sanghaya avatar sanghaya commented on June 2, 2024

Is it possible to share the logic between them, or any way to achieve the following:

  1. Access hooks from Main app
  2. Access AsyncStorage in Share.js from Main app
  3. Import third-party packages to Share.js (e.g. Apollo)

I tried adding the AsyncStorage directly to the Share.js but I get this error:

Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

I think I would also be ok if there is a way to have a separated package.json for Share.js if necessary, but @Gustash maybe you can put some more light on this topic?

Did anyone manage to solve this? I re-installed AsyncStorage to the latest version and manually added to Podfile under ShareExtension after I wrapped the file in Provider. But I'm still having this issue.

Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

from react-native-share-menu.

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.