The Ionic Native social sharing plugin keeps having issues with rxjs. What can I do to fix this issue?

huangapple go评论58阅读模式
英文:

The Ionic Native social sharing plugin keeps having issues with rxjs. What can I do to fix this issue?

问题

我已经在StackBlitz项目中遇到了这个问题。

https://stackblitz.com/edit/ionic6-angular13-yngs1m?file=src/app/app.component.css

每当我尝试使用这个插件时,都会收到一个关于Ionic Native不兼容的rxjs错误。我尝试过使用--force和--legacy-peer-deps安装它,还尝试过降级rxjs,但都不起作用。无论我做什么,rxjs的版本始终是7.8.0。

要在你自己的环境中重现这个问题:

  1. 创建一个新的空白Ionic项目,使用Angular。
  2. 使用npm i @ionic-native/social-sharing@4安装@ionic-native/social-sharing@4插件。
  3. 在你的组件中导入该插件:import { SocialSharing } from '@ionic-native/social-sharing';
  4. 在构造函数中实例化SocialSharing:private socialSharing: SocialSharing

在我的情况下,当我运行应用程序时,就已经出现了rxjs的问题。

  1. 在一个方法中(在我的情况下是share() {})中添加以下代码到ts文件中:
let options = {
    subject: "主题",
    message: "消息"
}

this.socialSharing.shareWithOptions(options);

请告诉我是否知道解决这个问题的方法。我的目标是能够使用图片的本地路径分享图片。点击分享按钮将调用share()方法,并在iOS和Android上弹出本地分享窗口,用户可以选择使用哪个平台分享图片。

英文:

I have made a stackblitz project with the issue.

https://stackblitz.com/edit/ionic6-angular13-yngs1m?file=src/app/app.component.css

Whenever I try to use this plugin I get a rxjs error about incompatibility with Ionic Native. Ive tried installing it with --force and --legacy-peer-deps, and downgrading rxjs, which doesnt even work. Whatever I do, rxjs is always version 7.8.0.

To recreate this issue yourself in your own environment:

  1. Create a new blank Ionic project with Angular
  2. Install the @ionic-native/social-sharing@4 plugin with npm i @ionic-native/social-sharing@4.
  3. Import the plugin in your component with: import { SocialSharing } from '@ionic-native/social-sharing'.
  4. Instantiate SocialSharing in the constructor with: private socialSharing: SocialSharing

In my case, when I run the app I already get issues with rxjs.

  1. Add the following code to the ts in a method (in my case share() {}):

let options = {
subject: "Subject",
message: "Message"
}

this.socialSharing.shareWithOptions(options);

Let me know if you know a way to fix this issue. My goal is to be able to share images using their local path. Clicking the share button will call the share() method and bring up the native share window for IOS and Android where users can select which platform they want to use to share the image

答案1

得分: 3

@ionic-native 已被弃用并捐赠给社区。现在它被称为 @awesome-cordova-plugins,其第 6 版包括与最新版本的 rxjs 兼容性。

将任何 @ionic-native/whatever 包替换为其等效的 @awesome-cordova-plugins/whatever

英文:

@ionic-native is deprecated and was donated to the community. It’s now called @awesome-cordova-plugins, and versión 6 of it includes compatibility with latest rxjs.

Replace any @ionic-native/whatever package with its equivalent @awesome-cordova-plugins/whatever

huangapple
  • 本文由 发表于 2023年2月16日 19:17:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75471490.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定